Skip to content

Commit 8b626a2

Browse files
committed
[clang-format] Fix another bug in AlignConsecutiveAssignments
The ShouldShiftBeAdded lambda checks if extra space should be added before the wrapped part of a braced list. If the first element of the list is wrapped, no extra space should be added. Fixes #55161. Differential Revision: https://reviews.llvm.org/D124956
1 parent 8bb5b65 commit 8b626a2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
398398
Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace))
399399
return false;
400400
}
401+
if (Changes[ScopeStart].NewlinesBefore > 0)
402+
return false;
401403
return true;
402404
}
403405

clang/unittests/Format/FormatTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18023,6 +18023,12 @@ TEST_F(FormatTest, AlignWithLineBreaks) {
1802318023
"}",
1802418024
Style);
1802518025

18026+
verifyFormat("unsigned i = 0;\n"
18027+
"int a[] = {\n"
18028+
" 1234567890,\n"
18029+
" -1234567890};",
18030+
Style);
18031+
1802618032
Style.ColumnLimit = 120;
1802718033

1802818034
// clang-format off

0 commit comments

Comments
 (0)