mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Close hints when the cursor moves to a new hinting context
This commit is contained in:
1 parent
612188b9c3
commit
52d98980f0
4 files changed
+172
-20
No files matched your search
@@ -148,6 +148,22 @@ define(function (require, exports, module) {
|
||||
|
||||
runs(function () { callback(hintList); });
|
||||
}
|
||||
/*
|
||||
* Test if hints are close or not closed at a given position.
|
||||
*
|
||||
* @param {Object} provider - a CodeHintProvider object
|
||||
* @param {Object + jQuery.Deferred} hintObj - a hint response object,
|
||||
* possibly deferred
|
||||
* @param {line, ch} - new position to move to after hints are received.
|
||||
* @param {Boolean} expectedValue - true if hints should close,
|
||||
* false otherwise.
|
||||
*/
|
||||
function expectCloseHints(provider, hintObj, newPos, expectedValue) {
|
||||
_waitForHints(hintObj, function (hintList) {
|
||||
testEditor.setCursorPos(newPos);
|
||||
expect(provider.shouldCloseHints(JSCodeHints.getSession())).toBe(expectedValue);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Expect a given list of hints to be absent from a given hint
|
||||
@@ -443,7 +459,56 @@ define(function (require, exports, module) {
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
hintsAbsent(hintObj, ["case", "function", "var"]);
|
||||
});
|
||||
|
||||
|
||||
it("should close hints when move over '.' ", function () {
|
||||
testEditor.setCursorPos({ line: 17, ch: 11 });
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 10 }, true);
|
||||
});
|
||||
|
||||
it("should close hints only when move off the end of a property ", function () {
|
||||
testEditor.setCursorPos({ line: 17, ch: 11 });
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 12 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 13 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 14 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 15 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 16 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 17 }, true);
|
||||
});
|
||||
|
||||
it("should close hints only when move off the beginning of an identifier ", function () {
|
||||
testEditor.setCursorPos({ line: 17, ch: 10 });
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 9 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 8 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 17, ch: 7 }, true);
|
||||
});
|
||||
|
||||
it("should close hints only when move off the beginning of a keyword ", function () {
|
||||
testEditor.setCursorPos({ line: 24, ch: 7 });
|
||||
var hintObj = expectHints(JSCodeHints.jsHintProvider);
|
||||
hintsPresent(hintObj, ["var"]);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 24, ch: 6 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 24, ch: 5 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 24, ch: 4 }, false);
|
||||
expectCloseHints(JSCodeHints.jsHintProvider, hintObj,
|
||||
{ line: 24, ch: 3 }, true);
|
||||
});
|
||||
|
||||
it("should NOT list implicit hints on left-brace", function () {
|
||||
testEditor.setCursorPos({ line: 6, ch: 0 });
|
||||
expectNoHints(JSCodeHints.jsHintProvider, "{");
|
||||
|
||||
Reference in new issue
Block a user