diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d6c823e39b8..718a0193624 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1548,6 +1548,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, return 0; if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr)) return Line.MightBeFunctionDecl ? 50 : 500; + if (Left.is(tok::colon) && Left.is(TT_DictLiteral)) + return 100; if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket) return 100; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 6c8fd2962ad..d6785649cb3 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -131,6 +131,11 @@ TEST_F(FormatTestJS, ContainerLiterals) { " //\n" " a\n" "};"); + verifyFormat("var obj = {\n" + " fooooooooo: function(x) {\n" + " return x.zIsTooLongForOneLineWithTheDeclarationLine();\n" + " }\n" + "};"); } TEST_F(FormatTestJS, SpacesInContainerLiterals) { |