Skip to content

[clang-format] Inconsistent formatting for the last element of an initializer list with AlignAfterOpenBracket: BlockIndent in clang-format-20 #144560

Open
@vient

Description

@vient

Test case - both elements are identical

auto _ = {
    {"a",
     []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},

    {"a",
     []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},
}

clang-format-19

$ clang-format-19 -style="{AlignAfterOpenBracket: BlockIndent}" test.cpp
auto _ = {
    {"a",
     []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},

    {"a",
     []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},
}

clang-format-20 - note that second element got lambda start placed on the same line as "a"

$ clang-format-20 -style="{AlignAfterOpenBracket: BlockIndent}" test.cpp
auto _ = {
    {"a",
     []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},

    {"a", []() {
       return looooooooooooooooooooooooooooooooooooooooooooooooooong_fn();
     }},
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions