Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit 9969cae

Browse files
committed
clang-format: [JS] Array literal detection fix #3.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238839 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d6d2cf1 commit 9969cae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ class AnnotatingParser {
280280
Parent->isOneOf(tok::l_brace, tok::comma)) {
281281
Left->Type = TT_JsComputedPropertyName;
282282
} else if (Parent &&
283-
Parent->isOneOf(tok::at, tok::equal, tok::comma,
284-
tok::l_paren, tok::question, tok::colon)) {
283+
Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren,
284+
tok::l_square, tok::question, tok::colon)) {
285285
Left->Type = TT_ArrayInitializerLSquare;
286286
} else {
287287
BindingIncrease = 10;

unittests/Format/FormatTestJS.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ TEST_F(FormatTestJS, ArrayLiterals) {
257257
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
258258
" ccccccccccccccccccccccccccc\n"
259259
"]);");
260+
verifyFormat("var someVariable = SomeFuntion([\n"
261+
" [aaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbb],\n"
262+
"]);");
260263
verifyFormat("var someVariable = SomeFuntion(aaaa, [\n"
261264
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
262265
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"

0 commit comments

Comments
 (0)