|
@@ -118,7 +118,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
|
} else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
|
|
state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
|
|
|
readRegexp(stream);
|
|
|
- stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
|
|
|
+ stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
|
|
|
return ret("regexp", "string-2");
|
|
|
} else {
|
|
|
stream.eatWhile(isOperatorChar);
|
|
@@ -549,6 +549,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
|
}
|
|
|
function classBody(type, value) {
|
|
|
if (type == "variable" || cx.style == "keyword") {
|
|
|
+ if (value == "static") {
|
|
|
+ cx.marked = "keyword";
|
|
|
+ return cont(classBody);
|
|
|
+ }
|
|
|
cx.marked = "property";
|
|
|
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
|
|
return cont(functiondef, classBody);
|
|
@@ -600,6 +604,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
|
if (type == "if") return cont(expression, comprehension);
|
|
|
}
|
|
|
|
|
|
+ function isContinuedStatement(state, textAfter) {
|
|
|
+ return state.lastType == "operator" || state.lastType == "," ||
|
|
|
+ isOperatorChar.test(textAfter.charAt(0)) ||
|
|
|
+ /[,.]/.test(textAfter.charAt(0));
|
|
|
+ }
|
|
|
+
|
|
|
// Interface
|
|
|
|
|
|
return {
|
|
@@ -651,7 +661,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
|
else if (type == "form" && firstChar == "{") return lexical.indented;
|
|
|
else if (type == "form") return lexical.indented + indentUnit;
|
|
|
else if (type == "stat")
|
|
|
- return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
|
|
|
+ return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
|
|
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
|
|
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
|
|
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
|
@@ -663,6 +673,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
|
blockCommentEnd: jsonMode ? null : "*/",
|
|
|
lineComment: jsonMode ? null : "//",
|
|
|
fold: "brace",
|
|
|
+ closeBrackets: "()[]{}''\"\"``",
|
|
|
|
|
|
helperType: jsonMode ? "json" : "javascript",
|
|
|
jsonldMode: jsonldMode,
|