llvm-project
llvm-project copied to clipboard
[clang-format] Cannot disable array initializer bin packing
See https://reviews.llvm.org/D38636
This is still an issue, and the behaviour is quite inconsistent. When using AlignArrayOfStructures: Left or AlignArrayOfStructures: Right, it does put them each on one line, but using AlignArrayOfStructures: None results in the nested initializers being bin packed despite the fact that I have BinPackArguments: false and BinPackParameters: false.
It's also import to note that it ignores the usual behaviour where using a trailing comma in an array initializer should disable bin packing.
Would be nice to have this consistent with the behaviour of AlignAfterOpenBracket: BlockIndent (which works perfectly) as well.
With AlignArrayOfStructures: None:
things_t array_of_things[] = {
{ true, false }, { false, true }, { true, false },
{ false, true }, { true, false }, { false, true },
};
I don't want bin packing at all so this is no good.
With AlignArrayOfStructures: Left:
things_t array_of_things[] = {
{true, false},
{ false, true },
{ true, false},
{ false, true },
{ true, false},
{ false, true },
};
This is closer to what I want, but I'd prefer to be able to do this without having to align the columns. Also the top left cell is always misaligned for some reason, which is rather annoying.
With AlignArrayOfStructures: Right:
things_t array_of_things[] = {
{ true, false},
{false, true},
{ true, false},
{false, true},
{ true, false},
{false, true},
};
As above, but at least this doesn't have that problem with one of the cells being misaligned.
@llvm/issue-subscribers-clang-format
How to just stop disable bin packing? I want to keep line breaks even the line not exceed the max length.
BinPackArguments: false
BinPackParameters: false
Won't be helpful.
How to just stop disable bin packing? I want to keep line breaks even the line not exceed the max length.
BinPackArguments: false BinPackParameters: falseWon't be helpful.
yea I want to be able to align my arguments in a function anyway i want and this thing forces me to either have them to be on either one line/packed if over the column limit or one in each line.
Did you find a way to get over this limitation??
EDIT: Got a fix. Set both to true and then set column limit to 0. Works like charm. Setting it to zero is making it accept the break inserted by the user since there is no defined column limit