llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.14k stars 12.02k forks source link

[clang-format] Weird line breaks with `AlignAfterOpenBracket: BlockIndent` #103306

Open lukasberbuer opened 3 months ago

lukasberbuer commented 3 months ago

Following example showcases weird line-breaking choices with AlignAfterOpenBracket: BlockIndent:

Any ideas how to fix this? Can it be done just via the config?

.clang-format

---
BasedOnStyle: LLVM
AlignAfterOpenBracket: BlockIndent
AlignOperands: DontAlign
llvmbot commented 3 months ago

@llvm/issue-subscribers-bug

Author: Lukas Berbuer (lukasberbuer)

Following example showcases weird line-breaking choices with `AlignAfterOpenBracket: BlockIndent`: - Pure LLVM style: ```cpp auto result = std::optional<int>(123) .transform([](int n) { return n + 100; }) .transform([](int n) { // multiline lambda return std::to_string(n); }); ``` - With `AlignAfterOpenBracket: BlockIndent` 💥: ```cpp auto result = std::optional<int>(123).transform([](int n) { return n + 100; } ).transform([](int n) { // multiline lambda return std::to_string(n); }); ``` - Desired output: ```cpp auto result = std::optional<int>(123) .transform([](int n) { return n + 100; }) .transform([](int n) { // multiline lambda return std::to_string(n); }); ``` Any ideas how to fix this? Can it be done just via the config? ## `.clang-format` ```yaml --- BasedOnStyle: LLVM AlignAfterOpenBracket: BlockIndent AlignOperands: DontAlign ```