Skip to content

clang-format misindents field initializers inside range-based for initializer #73902

Closed
@ilya-biryukov

Description

@ilya-biryukov

Run clang-format on this code:

void test() {
    for (const TestCase& test_case : {
           TestCase{
               .a = 1,
               .b = "1",
           },
           TestCase{
               .a = 2,
               .b = "2",
           },
       })  {}
}

In the output, the field names for the second fields are misindented:

void test() {
  for (const TestCase& test_case : {
           TestCase{
               .a = 1,
     .b = "1",
           },
           TestCase{
               .a = 2,
      .b = "2",
           },
       }) {
  }
}

I expect them to be at the same level of indent as the first field.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions