When an l_brace is wrapped and the line above it ends with a
comment, the annotator adds ColumnLimit to the TotalLength of the
l_brace, so the actual column position of the l_brace must be
adjusted accordingly.
Fixes #57376.
Differential Revision: https://reviews.llvm.org/D132805
auto Length = LastToken->TotalLength;
if (OpeningBrace) {
assert(OpeningBrace != Tokens.front().Tok);
+ if (auto Prev = OpeningBrace->Previous;
+ Prev && Prev->TotalLength + ColumnLimit == OpeningBrace->TotalLength) {
+ Length -= ColumnLimit;
+ }
Length -= OpeningBrace->TokenText.size() + 1;
}
"}",
Style);
+ verifyFormat("if (a) // comment\n"
+ " b = 1;",
+ "if (a) // comment\n"
+ "{\n"
+ " b = 1;\n"
+ "}",
+ Style);
+
verifyFormat("if (a) {\n"
"Label:\n"
"}",