Skip to content

switch statement not auto-indented correctly #19

@ZevEisenberg

Description

@ZevEisenberg

When you declare a switch statement with switch[tab], the template looks like this:

switch (variable) {
    case 'value':
        # code...
        break;

    default:
        # code...
        break;
}

The code below the case and default is indented. However, when I try to add a new case by pressing return at the end of the first break;, everything stays indented one more to the right than the first case:

switch (variable) {
    case 'value':
        echo 'hello';
        break;
        case 2:
        echo 'hello';
        break;

    default:
        echo 'hello';
        break;
}

When I use Command-Option-[ to Indent Line / Section, most of the statement gets flattened and doesn't match the template:

switch (variable) {
    case 'value':
    echo 'hello';
    break;
    case 2:
    echo 'hello';
    break;

    default:
    echo 'hello';
    break;
}

I would like the auto-indent to make it look like this:

switch (variable) {
    case 'value':
        echo 'hello';
        break;
    case 2:
        echo 'hello';
        break;

    default:
        echo 'hello';
        break;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions