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

Enum case listing is formatted improperly #194

Closed bdrelling closed 6 years ago

bdrelling commented 6 years ago

Sorry for the ambiguous title, not exactly sure how to reference it.

In trying to auto format this:

    enum Foo {
        case
        one,
        two,
        three
    }

It chooses to do this:

    enum Foo {
        case
        one,
            two,
            three
    }
Jintin commented 6 years ago

Hi, according to the doc https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html I think in this moment you can use either:

    enum Foo {
        case one,
        case two,
        case three
    }

or

    enum Foo {
        case one, two, three
    }

And for swimat part. I don't know if this is a good format rule practice, but apple seems format this way even in switch.

    enum Foo {
        case
        one,
        two,
        three
    }

    switch foo {
    case
    .one,
    .two,
    .three:
    }

One reasonable way to correct it is

    enum Foo {
        case
            one,
            two,
            three
    }

Do you think this is better or not?

bdrelling commented 6 years ago

I think my expectation is that all of these work:

Note that the first one doesn't have trailing commas because case is declared at the start of each line.

    enum Foo {
        case one
        case two
        case three
    }
    enum Foo {
        case one, two, three
    }
    enum Foo {
        case
        one,
        two,
        three
    }

Does this help?

Jintin commented 6 years ago

Thanks

Jintin commented 6 years ago

Build 1.5.3 will release recently, you can try here first or wait for other install method like brew cask. https://github.com/Jintin/Swimat/releases/tag/v1.5.3