Skip to content

Commit b319d11

Browse files
eustasmarijnh
authored andcommitted
Fix: some properties are classified as keywords.
Example: a.do = 3; "do" is highlighted as a keyword. Solution: do not classify identifier as a keyword after the "." operator.
1 parent e0d19c5 commit b319d11

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mode/javascript/javascript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
8787
else {
8888
stream.eatWhile(/[\w\$_]/);
8989
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
90-
return known ? ret(known.type, known.style, word) :
90+
return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
9191
ret("variable", "variable", word);
9292
}
9393
}
@@ -316,6 +316,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
316316
return {
317317
tokenize: jsTokenBase,
318318
reAllowed: true,
319+
kwAllowed: true,
319320
cc: [],
320321
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
321322
localVars: null,
@@ -334,6 +335,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
334335
var style = state.tokenize(stream, state);
335336
if (type == "comment") return style;
336337
state.reAllowed = type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/);
338+
state.kwAllowed = type != '.';
337339
return parseJS(state, style, type, content, stream);
338340
},
339341

0 commit comments

Comments
 (0)