Open
Description
Hi,
I've discovered that the following C++ code requires two formatting passes to stabilize:
Source code: column 120
int aaaaaaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbb; //testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttestte
After the first pass, a space is added after the //
, making it column 121
int aaaaaaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbb; // testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttestte
After the second pass, the line breaks
int aaaaaaaaaaaaaaa =
bbbbbbbbbbbbbbbbbbbbbbbbbbbb; // testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttestte
I suspect that the first formatting pass doesn't account for the added space after the //
when calculating the column, which causes the second pass to detect that column=121 > ColumnLimit, resulting in the line break.
My environment:
- clang-format version 17.0.6 and version 18.1.4
.clang-format configuration:
Language: Cpp
ColumnLimit: 120
ReflowComments: true
SpacesInLineCommentPrefix:
Minimum : 1
Maximum : 1
Thank you for looking into this issue!
Best regards