google / swift

The Swift Programming Language
https://swift.org/
840 stars 66 forks source link

Unexpected newline before opening brace for method calls with trailing closures #266

Open andriichernenko opened 5 years ago

andriichernenko commented 5 years ago

I tried formatting the project I'm working on with swift-format (using default configuration with 4-space indentation) and noticed that the following code:

return Presentation(editProduct, style: .modalOrFlip)
    .onValue {
        $0.map { self.libraryStore.edit(.add(.product($0))) }
    }
    .onPresent {
        isEditingLibrary.value = true
}

is formatted as

return Presentation(editProduct, style: .modalOrFlip)
    .onValue
{
    $0.map { self.libraryStore.edit(.add(.product($0))) }
}
    .onPresent
{
    isEditingLibrary.value = true
}

As I understand, this is done according to the rule 5 in the Line Wrapping section of the Swift Style Guide. In my opinion, however, newlines before opening braces are unnecessary in this case and should not be added.