Skip to content

Commit 45d5e05

Browse files
neon-devmarijnh
authored andcommitted
[javascript-hint addon] Disable completion in json mode
When using the editor in "application/json" mode, the standard javascript autocompletion would show up once triggered. Although it's deactivated by default and doesn't make sense to enable autocompletion in JSON mode on its own, this change fixes incorrect completions once you combine the default completion with your own custom logic.
1 parent 261d10b commit 45d5e05

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

addon/hint/javascript-hint.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
// Find the token at the cursor
3333
var cur = editor.getCursor(), token = getToken(editor, cur);
3434
if (/\b(?:string|comment)\b/.test(token.type)) return;
35-
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
35+
var innerMode = CodeMirror.innerMode(editor.getMode(), token.state);
36+
if (innerMode.mode.helperType === "json") return;
37+
token.state = innerMode.state;
3638

3739
// If it's not a 'word-style' token, ignore the token.
3840
if (!/^[\w$_]*$/.test(token.string)) {

0 commit comments

Comments
 (0)