Skip to content

clang-format AlignArrayOfStructures has bad behavior on None #148096

Open
@EthanRutherford

Description

@EthanRutherford

AlignArrayOfStructures: None behaves bizarrely, doing more "alignment" IMO than Left or Right does.

None:

const std::vector<Vertex> vertices = { { { -0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f } },
                                     { { 0.5f, -0.5f }, { 0.0f, 1.0f, 0.0f } },
                                     { { 0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f } },
                                     { { -0.5f, 0.5f }, { 1.0f, 1.0f, 1.0f } } };

Left:

const std::vector<Vertex> vertices = {
    { { -0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f } },
    { { 0.5f, -0.5f },  { 0.0f, 1.0f, 0.0f } },
    { { 0.5f, 0.5f },   { 0.0f, 0.0f, 1.0f } },
    { { -0.5f, 0.5f },  { 1.0f, 1.0f, 1.0f } }
};

Expected behavior (but not possible with current clang-format, as far as I can tell):

const std::vector<Vertex> vertices = {
    { { -0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f } },
    { { 0.5f, -0.5f }, { 0.0f, 1.0f, 0.0f } },
    { { 0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f } },
    { { -0.5f, 0.5f }, { 1.0f, 1.0f, 1.0f } }
};

Additionally, in my actual setup where I use tabs, the alignment is totally broken.
For some reason it tries to use a mix of tabs and spaces to do the alignment, and gets it completely wrong. Not sure what it's expecting this tab to align with, but tabSize is set to 4 in my config.

Image

So, all three possible options for this setting are producing undesireable results.

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