Skip to content

Commit 7dfbf42

Browse files
committed
[javascript mode] Fix indentation after trailing-comma array
Closes #2753
1 parent f8f7cac commit 7dfbf42

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

mode/javascript/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
590590
}
591591
function maybeArrayComprehension(type) {
592592
if (type == "for") return pass(comprehension, expect("]"));
593-
if (type == ",") return cont(commasep(expressionNoComma, "]"));
593+
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
594594
return pass(commasep(expressionNoComma, "]"));
595595
}
596596
function comprehension(type) {

mode/javascript/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@
147147
MT("scary_regexp",
148148
"[string-2 /foo[[/]]bar/];");
149149

150+
MT("indent_strange_array",
151+
"[keyword var] [variable x] [operator =] [[",
152+
" [number 1],,",
153+
" [number 2],",
154+
"]];",
155+
"[number 10];");
156+
150157
var jsonld_mode = CodeMirror.getMode(
151158
{indentUnit: 2},
152159
{name: "javascript", jsonld: true}

0 commit comments

Comments
 (0)