[clang-format] `BreakAfterOpenBracketIf` is ignored unless `ContinuationIndentWidth` is also set to a value smaller than `IndentWidth * 2`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
.clang-format:
```yaml
BinPackArguments: false
BreakAfterOpenBracketIf: true
BreakBeforeCloseBracketIf: true
```
Demo C file:
```c
#include
int main() {
if (printf("%s %s %s %s %s %s", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar") < 0) {
return 1;
}
}
```
Expected formatting:
```c
#include
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:
```c
#include
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
Contributor guide
Assessment
This issue has not been assessed yet.