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

Indentation for nested switch/case and for cases with code on the same line is incorrect. #148

Open
deatondg opened this issue Apr 23, 2021 · 1 comment

Comments

@deatondg
Copy link

The following Swift file

switch readLine() {
case "1": print("1")
case "2":
print("2")
case "a": 
switch readLine() {
case "1": print("1")
default: print("Other")
}
default: print("Other")
}

(there is whitespace in "a": ) is indented like so

switch readLine() {
    case "1": print("1")
case "2":
    print("2")
    case "a": 
    switch readLine() {
        case "1": print("1")
        default: print("Other")
    }
    default: print("Other")
}

The expected behavior is for it to be indented as so:

switch readLine() {
case "1": print("1")
case "2":
    print("2")
case "a": 
    switch readLine() {
    case "1": print("1")
    default: print("Other")
    }
default: print("Other")
}

The detection for cases appears to expect the : to end the line, which is not required by Swift, and it appears to align a case with the previous use of switch instead of the switch it is actually part of. The syntax highlighting still appears correct.

@keith
Copy link
Owner

keith commented Apr 23, 2021

Not super surprised. Probably not an easy one to fix since they can be infinitely nested as well ☹️

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

No branches or pull requests

2 participants