File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,13 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
348
348
}
349
349
}
350
350
351
+ // Don't allow breaking before a closing right brace of a block-indented
352
+ // braced list initializer if there was not already a break.
353
+ if (Current.is (tok::r_brace) && Current.MatchingParen &&
354
+ Current.isBlockIndentedInitRBrace (Style )) {
355
+ return CurrentState.BreakBeforeClosingBrace ;
356
+ }
357
+
351
358
// If binary operators are moved to the next line (including commas for some
352
359
// styles of constructor initializers), that's always ok.
353
360
if (!Current.isOneOf (TT_BinaryOperator, tok::comma) &&
Original file line number Diff line number Diff line change @@ -9336,6 +9336,9 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
9336
9336
" ccccccc(aaaaaaaaaaaaaaaaa, //\n"
9337
9337
" b));",
9338
9338
Style);
9339
+ verifyFormat("aaaaaaa<bbbbbbbb> const aaaaaaaaaa{\n"
9340
+ " aaaaaaaaaaaaa(aaaaaaaaaaa, aaaaaaaaaaaaaaaa)};",
9341
+ Style);
9339
9342
9340
9343
Style.ColumnLimit = 30;
9341
9344
verifyFormat("for (int foo = 0; foo < FOO;\n"
@@ -9395,6 +9398,9 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
9395
9398
"fooooooooooo(new FOO::BARRRR(\n"
9396
9399
" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZZZZZZZZZZZZZ()));",
9397
9400
Style);
9401
+ verifyFormat("aaaaaaa<bbbbbbbb> const aaaaaaaaaa{\n"
9402
+ " aaaaaaaaaaaaa(aaaaaaaaaaa, aaaaaaaaaaaaaaaa)};",
9403
+ Style);
9398
9404
9399
9405
Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
9400
9406
Style.BinPackArguments = false;
@@ -9441,6 +9447,11 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
9441
9447
" aaaaaaaaaaaaaaaa\n"
9442
9448
");",
9443
9449
Style);
9450
+ verifyFormat("aaaaaaa<bbbbbbbb> const aaaaaaaaaa{\n"
9451
+ " aaaaaaaaaaaaa(aaaaaaaaaaa, aaaaaaaaaaaaaaaa)\n"
9452
+ "};",
9453
+ Style);
9454
+
9444
9455
verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
9445
9456
" const bool &aaaaaaaaa, const void *aaaaaaaaaa\n"
9446
9457
") const {\n"
You can’t perform that action at this time.
0 commit comments