Skip to content

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

@lukasberbuer

Description

@lukasberbuer

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

  • Pure LLVM style:

    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 💥:

    auto result = std::optional<int>(123).transform([](int n) { return n + 100; }
    ).transform([](int n) {
        // multiline lambda
        return std::to_string(n);
    });
  • Desired output:

    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

---
BasedOnStyle: LLVM
AlignAfterOpenBracket: BlockIndent
AlignOperands: DontAlign

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions