Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit c4e9760

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

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ class AnnotatingParser {
281281
Left->Type = TT_JsComputedPropertyName;
282282
} else if (Parent &&
283283
Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren,
284-
tok::l_square, tok::question, tok::colon)) {
284+
tok::l_square, tok::question, tok::colon,
285+
tok::kw_return)) {
285286
Left->Type = TT_ArrayInitializerLSquare;
286287
} else {
287288
BindingIncrease = 10;

unittests/Format/FormatTestJS.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
252252
" new SomeThingAAAAAAAAAAAA(),\n"
253253
" new SomeThingBBBBBBBBB()\n"
254254
"];");
255+
verifyFormat("return [\n"
256+
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
257+
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
258+
" ccccccccccccccccccccccccccc\n"
259+
"];");
255260
verifyFormat("var someVariable = SomeFuntion([\n"
256261
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
257262
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"

0 commit comments

Comments
 (0)