[clangformat] Array and autoformat

Not sure if this deserves a new topic. Anybody any idea how I can prevent the array formatting from doing the below.

void someFunc()
{
  byte a[] = { 0, 0x5e, 0x52, 0x52, 0x52, 0x52, 0x5e, 0, };  //makes 10
}

After autoformat

void someFunc()
{
  byte a[] = {
    0,
    0x5e,
    0x52,
    0x52,
    0x52,
    0x52,
    0x5e,
    0,
  };  //makes 10
}

The cause is the last comma before the } in the array initialisation.

I did search the documentation (Clang-Format Style Options — Clang 14.0.0 documentation) for 'array' but did not spot anything that immediately said "that's it". My .clangformat is attached.

.clang-format.zip (1.6 KB)

Tried playing with Cpp11BracedListStyle (set to true or false)?
Can’t try at the moment

Tried that now, thanks. Made no difference :cry: Maybe in combination with something else but unless you need the challenge ( :smiley: ), you can leave it.

I know the work around. It's mostly for when I autoformat a poster's code that it annoys the crap out of me; undo, remove the commas and autoformat again.

may be AllowAllArgumentsOnNextLine as it applies to braces too and change ColumnLimit ?

annoying I agree !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.