[clang-format] `BreakAfterOpenBracketIf` is ignored unless `ContinuationIndentWidth` is also set to a value smaller than `IndentWidth * 2`
.clang-format:
BinPackArguments: false
BreakAfterOpenBracketIf: true
BreakBeforeCloseBracketIf: true
Demo C file:
#include <stdio.h>
int main() {
if (printf("%s %s %s %s %s %s", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar") < 0) {
return 1;
}
}
Expected formatting:
#include <stdio.h>
int main() {
if (
printf("%s %s %s %s %s %s",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar") < 0
) {
return 1;
}
}
(i.e., newline should be inserted after opening parenthesis of the if statement.)
Actual formatting:
#include <stdio.h>
int main() {
if (printf("%s %s %s %s %s %s",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar") < 0) {
return 1;
}
}
If ContinuationIndentWidth rule is set to a value less than IndentWidth multiplied by 2 (like 3 or 2) then the formatting is as expected. I tried changing various Penalty* rules but it didn't help.
clang-format version is 22.1.8
@llvm/issue-subscribers-clang-format
Author: arthur-cornfield
Demo C file:
#include <stdio.h>
int main() {
if (printf("%s %s %s %s %s %s", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar") < 0) {
return 1;
}
}
Expected formatting:
#include <stdio.h>
int main() {
if (
printf("%s %s %s %s %s %s",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar") < 0
) {
return 1;
}
}
(i.e., newline should be inserted after opening parenthesis of the if statement.)
Actual formatting:
#include <stdio.h>
int main() {
if (printf("%s %s %s %s %s %s",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar",
"foobar") < 0) {
return 1;
}
}
If ContinuationIndentWidth rule is set to a value less than IndentWidth multiplied by 2 (like 3 or 2) then the formatting is as expected. I tried changing various Penalty* rules but it didn't help.
Hi, I would like to work on this issue. Could you assign it to me? Thank you!