Skip to content

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

@deatondg

Description

@deatondg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions