nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.91k stars 639 forks source link

trailingCommas does not handle nested arrays #572

Open ochristensen opened 4 years ago

ochristensen commented 4 years ago
let a = [["a"]]

does not produce

let a = [["a",],]

as expected

nicklockwood commented 4 years ago

Trailing commas are only applied if the array is split over multiple lines, e.g.

let a = [
  [
    "a",
  ],
]
ochristensen commented 4 years ago

is there a rule to make that splitting happen automatically?

nicklockwood commented 4 years ago

@ochristensen only if the array literal exceeds the maxwidth value for lines, or if the array literal already contains a linebreak.