nicklockwood / SwiftFormat

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

Implement Combined before-first and after-first Wrap Arguments #1573

Open KevinDoremy opened 8 months ago

KevinDoremy commented 8 months ago

Initial Swift code:

Text("")
    .padding(EdgeInsets(top: 0, leading: 0,
                        bottom: 0, trailing: 0)
    )

Expected result using swiftformat file.swift --wraparguments after-first:

Text("")
    .padding(EdgeInsets(top: 0,
                        leading: 0,
                        bottom: 0,
                        trailing: 0)
    )

Actual result using swiftformat file.swift --wraparguments after-first:

Text("")
    .padding(EdgeInsets(top: 0, leading: 0,
                        bottom: 0, trailing: 0)
    )

To get the expected result, we need to use the following commands before-first and after-first the swiftformat command:

swiftformat file.swift --wraparguments before-first

Text("")
    .padding(EdgeInsets(
        top: 0,
        leading: 0,
        bottom: 0,
        trailing: 0
    )

then swiftformat file.swift --wraparguments after-first

Text("")
    .padding(EdgeInsets(top: 0,
                        leading: 0,
                        bottom: 0,
                        trailing: 0)
    )

I think it would be great to have a command that would allow us to do this in one command