Skip to content

Commit

Permalink
[javascript-hint addon] Disable completion in json mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
neon-dev authored and marijnh committed Mar 19, 2018
1 parent 261d10b commit 45d5e05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addon/hint/javascript-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
// Find the token at the cursor
var cur = editor.getCursor(), token = getToken(editor, cur);
if (/\b(?:string|comment)\b/.test(token.type)) return;
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
var innerMode = CodeMirror.innerMode(editor.getMode(), token.state);
if (innerMode.mode.helperType === "json") return;
token.state = innerMode.state;

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

0 comments on commit 45d5e05

Please sign in to comment.