[clang] [clang-format] Fix poor spacing in `AlignArrayOfStructures: Left` (PR #77868)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 20 13:18:18 PST 2024
================
@@ -1366,11 +1366,12 @@ void WhitespaceManager::alignArrayInitializersLeftJustified(
auto &Cells = CellDescs.Cells;
// Now go through and fixup the spaces.
auto *CellIter = Cells.begin();
- // The first cell needs to be against the left brace.
- if (Changes[CellIter->Index].NewlinesBefore == 0)
- Changes[CellIter->Index].Spaces = BracePadding;
- else
- Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
+ // The first cell of every row needs to be against the left brace.
+ for (const auto *Next = CellIter; Next; Next = Next->NextColumnElement)
+ if (Changes[Next->Index].NewlinesBefore == 0)
+ Changes[Next->Index].Spaces = BracePadding;
+ else
+ Changes[Next->Index].Spaces = CellDescs.InitialSpaces;
----------------
owenca wrote:
```suggestion
for (const auto *Next = CellIter; Next; Next = Next->NextColumnElement) {
auto &Change = Changes[Next->Index];
Change.Spaces = Change.NewlinesBefore == 0 ? BracePadding : CellDescs.InitialSpaces;
}
```
https://github.com/llvm/llvm-project/pull/77868
More information about the cfe-commits
mailing list