nicklockwood / SwiftFormat

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

Indent regression after multi-line argument value #1019

Closed calda closed 3 years ago

calda commented 3 years ago

I noticed a regression in the indent rule, following multi-line argument values in method calls:

Before

enum Namespace {
  class ContentPresenter {
    func makeEpoxyModel() -> EpoxyModeling {
      LegacyEpoxyModelBuilder<BasicRow>(
        dataID: DataID.dismissModalBody.rawValue,
        content: .init(titleText: content.title, subtitleText: content.bodyHtml),
        style: Style.standard
          .with(property: newValue)
          .with(anotherProperty: newValue))
        .with(configurer: { view, content, _, _ in
          view.setHTMLText(content.subtitleText?.unstyledText)
        })
        .build()
    }
  }
}

After running swiftformat . --rules indent --indent 2 in 0.48.12

enum Namespace {
  class ContentPresenter {
    func makeEpoxyModel() -> EpoxyModeling {
      LegacyEpoxyModelBuilder<BasicRow>(
        dataID: DataID.dismissModalBody.rawValue,
        content: .init(titleText: content.title, subtitleText: content.bodyHtml),
        style: Style.standard
          .with(property: newValue)
          .with(anotherProperty: newValue))
                .with(configurer: { view, content, _, _ in // four levels of unexpected indentation
                  view.setHTMLText(content.subtitleText?.unstyledText)
                })
                .build()
    }
  }
}

This doesn't happen if I replace:

style: Style.standard
  .with(property: newValue)
  .with(anotherProperty: newValue))

with just style: style).

nicklockwood commented 3 years ago

@calda it looks like this was introduced in 0.48.5.

nicklockwood commented 3 years ago

@calda fixed in 0.48.14

calda commented 3 years ago

Thanks!