[clang-format] BreakAfterOpenBracketIf has no effect when ContinuationIndentWidth >=4
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`BreakAfterOpenBracketIf` has no effect when `ContinuationIndentWidth >=4`. That is, the following line:
```
if (first_very_very_very_very_long_condition && second_very_very_very_very_long_condition) {
```
is formatted as follows (or alike depending on other options):
```
if (first_very_very_very_very_long_condition &&
second_very_very_very_very_long_condition) {
```
Although the desired formatting would be as follows:
```
if (
first_very_very_very_very_long_condition &&
second_very_very_very_very_long_condition
) {
```
My understanding is that this is due to the logic described in [this comment](https://github.com/llvm/llvm-project/blob/708d1c1b8c2468a366f6914b88eaa3f3a4c932b0/clang/lib/Format/ContinuationIndenter.cpp#L875). I'm not sure what the target scenario for this logic is, but with `ContinuationIndentWidth >=4`, it effectively defeats the purpose of `BreakAfterOpenBracketIf`. Would removing the respective "conservation" check break anything?
Contributor guide
Research direction
Start in clang/lib/Format/ContinuationIndenter.cpp at the conservation logic referenced in the issue, and trace how it interacts with BreakAfterOpenBracketIf and ContinuationIndentWidth. The work is done when the shown condition is formatted with a break immediately after the opening bracket and before the closing bracket, without regressing the related formatting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100