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

Commit

Permalink
clang-format: [JS] Array literal detection fix #4.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238873 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
djasper committed Jun 2, 2015
1 parent e03b8fa commit c4e9760
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ class AnnotatingParser {
Left->Type = TT_JsComputedPropertyName;
} else if (Parent &&
Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren,
tok::l_square, tok::question, tok::colon)) {
tok::l_square, tok::question, tok::colon,
tok::kw_return)) {
Left->Type = TT_ArrayInitializerLSquare;
} else {
BindingIncrease = 10;
Expand Down
5 changes: 5 additions & 0 deletions unittests/Format/FormatTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
" new SomeThingAAAAAAAAAAAA(),\n"
" new SomeThingBBBBBBBBB()\n"
"];");
verifyFormat("return [\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
" ccccccccccccccccccccccccccc\n"
"];");
verifyFormat("var someVariable = SomeFuntion([\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
Expand Down

0 comments on commit c4e9760

Please sign in to comment.