Swimat icon indicating copy to clipboard operation
Swimat copied to clipboard

Indent switch/case labels

Open firetrap opened this issue 6 years ago • 3 comments

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

firetrap avatar Nov 14 '19 23:11 firetrap

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

Jintin avatar Nov 15 '19 02:11 Jintin

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

Jintin avatar Jan 28 '20 15:01 Jintin

I think that firetrap want to said below

There is an option in Text Editing, Xcode preference


Indent switch/case labels in

  • [ ] Swift
  • [ ] C/Objective-C/C++

switch condition {
case a:
    break;
}

and

switch condition {
    case a:
        break;
}

I also want this :smile:

TaejinPark avatar Feb 02 '23 16:02 TaejinPark