X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=Source%2FWebInspectorUI%2FTools%2FPrettyPrinting%2FCodeMirrorFormatters.js;h=a4075d40adfdd8edf0a7f1db5b76b4d16bc19002;hp=296d0e7e54906265631331deabf0fad92ed4a7b9;hb=4d10d6819898955c97ef55767fba65837903b007;hpb=300a6d39c474b56c34104a8ba4372514132274b5;ds=sidebyside diff --git a/Source/WebInspectorUI/Tools/PrettyPrinting/CodeMirrorFormatters.js b/Source/WebInspectorUI/Tools/PrettyPrinting/CodeMirrorFormatters.js index 296d0e7e5490..a4075d40adfd 100644 --- a/Source/WebInspectorUI/Tools/PrettyPrinting/CodeMirrorFormatters.js +++ b/Source/WebInspectorUI/Tools/PrettyPrinting/CodeMirrorFormatters.js @@ -35,14 +35,18 @@ CodeMirror.extendMode("javascript", { return lastToken && /\bkeyword\b/.test(lastToken) && (lastContent !== "function" && lastContent !== "typeof" && lastContent !== "instanceof"); if (content === ":") // Ternary. return (state.lexical.type === "stat" || state.lexical.type === ")"); - if (content === "!") // Unary ! should not be confused with "!=". - return false; - return "+-/*&&||!===+=-=>=<=?".indexOf(content) >= 0; // Operators. + return false; } if (isComment) return true; + if (/\boperator\b/.test(token)) { + if (content === "!") // Unary ! should not be confused with "!=". + return false; + return "+-/*&&||!===+=-=>=<=?".indexOf(content) >= 0; // Operators. + } + if (/\bkeyword\b/.test(token)) { // Most keywords require spaces before them, unless a '}' can come before it. if (content === "else" || content === "catch" || content === "finally") return lastContent === "}";