Skip to content
Snippets Groups Projects
Commit 27fe44c3 authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[javascript mode] Be more conservative about detecting fat arrow syntax

So that => in a string or comment doesn't trigger weird indentation.

Closes #2993
parent 965b8dd1
No related branches found
No related tags found
No related merge requests found
......@@ -205,6 +205,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
++depth;
} else if (wordRE.test(ch)) {
sawSomething = true;
} else if (/["'\/]/.test(ch)) {
return;
} else if (sawSomething && !depth) {
++pos;
break;
......
......@@ -61,6 +61,12 @@
" [keyword yield] [variable-2 i];",
"}");
MT("quotedStringAddition",
"[keyword let] [variable f] [operator =] [variable a] [operator +] [string 'fatarrow'] [operator +] [variable c];");
MT("quotedFatArrow",
"[keyword let] [variable f] [operator =] [variable a] [operator +] [string '=>'] [operator +] [variable c];");
MT("fatArrow",
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
"[variable a];", // No longer in scope
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment