Skip to content

[clang-format] AlignArrayOfStructures With Tabs #138151

Open
@GMeulendyks

Description

@GMeulendyks

Aligning an array of structures with UseTab: AlignWithSpaces does not format correctly.
Of note, switching to UseTab: Never does resolve the issue.

#define LONG_NAME 1
#define LONGER_NAME 2
#define THIS_IS_A_VERY_LONG_NAME 3

int i = 1 << 0;
int j = 1 << 1;

struct Foo
{
	int a;
	int b;
	int c;
};

std::vector<Foo> foos = {
	{LONG_NAME,				0,						i | j},
	{LONG_NAME,				0,						i | j},
	{LONGER_NAME,              0,						i | j},
	{LONGER_NAME,              0,						i    },
	{THIS_IS_A_VERY_LONG_NAME, 0,                        j    },
	{LONGER_NAME,              THIS_IS_A_VERY_LONG_NAME, i    },
	{LONG_NAME,				THIS_IS_A_VERY_LONG_NAME, j    }
};

Relevant .clang-format options:

---
Language: Cpp
BasedOnStyle: Google

AlignArrayOfStructures: Left
UseTab: AlignWithSpaces
IndentWidth: 4
TabWidth: 4

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