diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 308fc623d82..5d59f19edfb 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -146,7 +146,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (Style.AlwaysBreakBeforeMultilineStrings && State.Column > State.Stack.back().Indent && // Breaking saves columns. !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at) && - Previous.Type != TT_InlineASMColon && nextIsMultilineString(State)) + Previous.Type != TT_InlineASMColon && + Previous.Type != TT_ConditionalExpr && nextIsMultilineString(State)) return true; if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) || Previous.Type == TT_ArrayInitializerLSquare) && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index cf5c9ff1efb..584ecba9866 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4167,6 +4167,12 @@ TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) { " L\"cccc\");", Break); + // As we break before unary operators, breaking right after them is bad. + verifyFormat("string foo = abc ? \"x\"\n" + " \"blah blah blah blah blah blah\"\n" + " : \"y\";", + Break); + // Don't break if there is no column gain. verifyFormat("f(\"aaaa\"\n" " \"bbbb\");", |