vendor/assets/javascripts/codemirror/modes/javascript.js in codemirror-rails-4.4 vs vendor/assets/javascripts/codemirror/modes/javascript.js in codemirror-rails-4.5
- old
+ new
@@ -17,10 +17,11 @@
var indentUnit = config.indentUnit;
var statementIndent = parserConfig.statementIndent;
var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;
+ var wordRE = parserConfig.wordCharacters || /[\w$]/;
// Tokenizer
var keywords = function(){
function kw(type) {return {type: type, style: "keyword"};}
@@ -130,12 +131,12 @@
stream.skipToEnd();
return ret("error", "error");
} else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return ret("operator", "operator", stream.current());
- } else {
- stream.eatWhile(/[\w\$_]/);
+ } else if (wordRE.test(ch)) {
+ stream.eatWhile(wordRE);
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
ret("variable", "variable", word);
}
}
@@ -200,11 +201,11 @@
if (bracket >= 0 && bracket < 3) {
if (!depth) { ++pos; break; }
if (--depth == 0) break;
} else if (bracket >= 3 && bracket < 6) {
++depth;
- } else if (/[$\w]/.test(ch)) {
+ } else if (wordRE.test(ch)) {
sawSomething = true;
} else if (sawSomething && !depth) {
++pos;
break;
}
@@ -667,10 +668,10 @@
jsonldMode: jsonldMode,
jsonMode: jsonMode
};
});
-CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/);
+CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");
CodeMirror.defineMIME("application/javascript", "javascript");
CodeMirror.defineMIME("application/x-javascript", "javascript");