mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Fix Issue #3614
Don't hint on function, parameter, or variable declarations. no hints for var fo// we used to pop up hints here
This commit is contained in:
1 parent
03d0c0766f
commit
dfdff356a6
4 files changed
+35
-1
No files matched your search
@@ -76,6 +76,8 @@ define(function (require, exports, module) {
|
||||
case "comment":
|
||||
case "number":
|
||||
case "regexp":
|
||||
// exclude variable & param decls
|
||||
case "def":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
||||
@@ -532,5 +532,19 @@ define(function (require, exports, module) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Deterimine if the cursor is located in the name of a function declaration.
|
||||
* This is so we can suppress hints when in a funtion name, as we do for variable and
|
||||
* parameter declarations, but we can tell those from the token itself rather than having
|
||||
* to look at previous tokens.
|
||||
*/
|
||||
Session.prototype.isFunctionName = function () {
|
||||
var cursor = this.getCursor(),
|
||||
token = this.getToken(cursor),
|
||||
prevToken = this._getPreviousToken(cursor);
|
||||
|
||||
return prevToken.string === "function";
|
||||
};
|
||||
|
||||
module.exports = Session;
|
||||
});
|
||||
@@ -268,6 +268,9 @@ define(function (require, exports, module) {
|
||||
|
||||
// don't autocomplete within strings or comments, etc.
|
||||
if (token && HintUtils.hintable(token)) {
|
||||
if (session.isFunctionName()) {
|
||||
return false;
|
||||
}
|
||||
var offset = session.getOffset(),
|
||||
type = session.getType(),
|
||||
query = session.getQuery();
|
||||
|
||||
@@ -945,7 +945,7 @@ define(function (require, exports, module) {
|
||||
expect(testDoc.getLine(end.line).length).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should jump to function", function () {
|
||||
var start = { line: 43, ch: 0 };
|
||||
|
||||
@@ -1017,6 +1017,21 @@ define(function (require, exports, module) {
|
||||
editorJumped({line: 94, ch: 45});
|
||||
});
|
||||
});
|
||||
|
||||
it("should not hint function, variable, or param decls", function () {
|
||||
var func = { line: 7, ch: 12 },
|
||||
param = { line: 7, ch: 18 },
|
||||
variable = { line: 10, ch: 10 };
|
||||
|
||||
runs(function () {
|
||||
testEditor.setCursorPos(func);
|
||||
expectNoHints(JSCodeHints.jsHintProvider);
|
||||
testEditor.setCursorPos(param);
|
||||
expectNoHints(JSCodeHints.jsHintProvider);
|
||||
testEditor.setCursorPos(variable);
|
||||
expectNoHints(JSCodeHints.jsHintProvider);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("JavaScript Code Hinting in a HTML file", function () {
|
||||
|
||||
Reference in new issue
Block a user