diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 14 |
2 files changed, 8 insertions, 9 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 828e7507626..afd20b22e3a 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -643,7 +643,8 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, State.Stack[State.Stack.size() - 2].JSFunctionInlined = false; } if (Current.TokenText == "function") - State.Stack.back().JSFunctionInlined = !Newline; + State.Stack.back().JSFunctionInlined = + !Newline && Previous && Previous->Type != TT_DictLiteral; } moveStatePastFakeLParens(State, Newline); diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index bd931aaf0a3..b161699d943 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -110,14 +110,12 @@ TEST_F(FormatTestJS, ContainerLiterals) { "};"); verifyFormat("return {\n" " a: a,\n" - " link:\n" - " function() {\n" - " f(); //\n" - " },\n" - " link:\n" - " function() {\n" - " f(); //\n" - " }\n" + " link: function() {\n" + " f(); //\n" + " },\n" + " link: function() {\n" + " f(); //\n" + " }\n" "};"); verifyFormat("var stuff = {\n" " // comment for update\n" |