Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent switch/case labels #216

Open
firetrap opened this issue Nov 14, 2019 · 3 comments
Open

Indent switch/case labels #216

firetrap opened this issue Nov 14, 2019 · 3 comments

Comments

@firetrap
Copy link
Contributor

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
Copy link
Owner

Jintin commented Nov 15, 2019

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

@Jintin
Copy link
Owner

Jintin commented Jan 28, 2020

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

@TaejinPark
Copy link

TaejinPark commented Feb 2, 2023

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants