diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 5 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 17af2fa5f25..380532a47cc 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -426,8 +426,9 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, } else if (NextNonComment->Type == TT_StartOfName || Previous.isOneOf(tok::coloncolon, tok::equal)) { State.Column = ContinuationIndent; - } else if (PreviousNonComment && - PreviousNonComment->Type == TT_ObjCMethodExpr) { + } else if (PreviousNonComment && PreviousNonComment->is(tok::colon) && + (PreviousNonComment->Type == TT_ObjCMethodExpr || + PreviousNonComment->Type == TT_DictLiteral)) { State.Column = ContinuationIndent; // FIXME: This is hacky, find a better way. The problem is that in an ObjC // method expression, the block should be aligned to the line starting it, diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5d4c1172c13..5bd0822281e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6011,6 +6011,11 @@ TEST_F(FormatTest, ObjCDictLiterals) { " NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : " "regularFont,\n" "};"); + verifyFormat( + "@{\n" + " NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :\n" + " reeeeeeeeeeeeeeeeeeeeeeeegularFont,\n" + "};"); // We should try to be robust in case someone forgets the "@". verifyFormat( |