-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang-format] Weird line breaks with AlignAfterOpenBracket: BlockIndent
#103306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-bug Author: Lukas Berbuer (lukasberbuer)
Following example showcases weird line-breaking choices with `AlignAfterOpenBracket: BlockIndent`:
Any ideas how to fix this? Can it be done just via the config?
|
Near the ColumnLimit a break could be inserted before a right parens with BlockIndent without a break after the matching left parens. Avoid these hanging right parens by disallowing breaks before right parens unless there was a break after the left parens. Fixes llvm#103306
You can achieve this with the style option from #118409 to reduce the penalty for breaking before the member access, and the fix (pending) from #124998 to avoid breaking the right parens of You need to set a penalty much lower than the default. 30 seemed to do the trick:
|
Thanks @gedare, this solves most of this formatting issue. - auto result = std::optional<int>(123)
- .transform([](int n) { return n + 100; });
+ auto result = std::optional<int>(123)
+ .transform([](int n) { return n + 100; }); |
The |
Near the ColumnLimit a break could be inserted before a right parens with BlockIndent without a break after the matching left parens. Avoid these hanging right parens by disallowing breaks before right parens unless there was a break after the left parens. Fixes llvm#103306 (cherry picked from commit b873479)
Following example showcases weird line-breaking choices with
AlignAfterOpenBracket: BlockIndent
:Pure LLVM style:
With
AlignAfterOpenBracket: BlockIndent
💥:Desired output:
Any ideas how to fix this? Can it be done just via the config?
.clang-format
The text was updated successfully, but these errors were encountered: