Jintin / Swimat

An Xcode formatter plug-in to format your swift code.
https://jintin.github.io/Swimat/
MIT License
1.65k stars 89 forks source link

Weird indentation with type inference on methods #230

Open simonbromberg opened 3 years ago

simonbromberg commented 3 years ago

What is the issue Swimat's indentation seems to behave incorrectly with lines beginning with . which are inferring a type.

For example:

func myFunction() -> MyClass {
        .init(
        myParam: someValue
    )
}

If it were MyClass above instead of .init the indentation works as expected, but it's nicer to use type inference.

Even a single line indents too much:

func myFunction() -> UIView {
        .init(frame: .zero)
}

Expected behavior

func myFunction() -> MyClass {
    .init(
        myParam: someValue
    )
}

Desktop (please complete the following information):

Additional context Does this in the Preview tool of the Swimat macOS app too.

frederickjjoubert commented 3 years ago

I'm getting the same thing with single lines being indented too much:


init() {
    UINavigationBar.appearance().largeTitleTextAttributes = [
            .foregroundColor: UIColor.white // This line is indented twice
    ]
}

Thanks for the awesome tool @Swimat team, can't wait for more improvements