Skip to content

Commit 5e0fc93

Browse files
authored
[clang-format] Fix a bug in AlignAfterOpenBracket: DontAlign (#94561)
Fixes #94555.
1 parent aae025a commit 5e0fc93

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
17121712
(!Previous || Previous->isNot(tok::kw_return) ||
17131713
(Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) &&
17141714
(Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
1715-
PrecedenceLevel != prec::Comma || Current.NestingLevel == 0) &&
1715+
PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
17161716
(!Style.isTableGen() ||
17171717
(Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
17181718
TT_TableGenDAGArgListCommaToBreak)))) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9241,6 +9241,14 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
92419241
" b));",
92429242
Style);
92439243

9244+
Style.ColumnLimit = 30;
9245+
verifyFormat("for (int foo = 0; foo < FOO;\n"
9246+
" ++foo) {\n"
9247+
" bar(foo);\n"
9248+
"}",
9249+
Style);
9250+
Style.ColumnLimit = 80;
9251+
92449252
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
92459253
Style.BinPackArguments = false;
92469254
Style.BinPackParameters = false;

0 commit comments

Comments
 (0)