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

Indent switch/case labels #216

Open firetrap opened 4 years ago

firetrap commented 4 years ago

Can you indent switch cases like the xcode when you select it in Text editing preferences. On alternative can be a option in Swimat settings.

I tried editing your code with some success and a little bug with the break keyword after the break it will add another indent to the next case.

var checkInCase = false
    if indent.inSwitch {
        if isNext(word: "case") {
            checkInCase = true
            indent.count += 1
            indent.inCase = true
        } else if isNext(word: "default") || isNext(word: "@unknown") || isNext(word: "break") {
            indent.extra -= 1
        }
    }

Another suggestion it's the break be at the same level as the case but this is just a opinion

Jintin commented 4 years ago

I don't really get your mean, can you post some example please?

Jintin commented 4 years ago

What is the other type you want to propose? @firetrap

TaejinPark commented 1 year ago

I think that firetrap want to said below

There is an option in Text Editing, Xcode preference


Indent switch/case labels in

switch condition {
case a:
    break;
}

and

switch condition {
    case a:
        break;
}

I also want this :smile: