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

Respect new lines between case statements #383

Closed
pmccloghrylaing opened this issue Jul 29, 2021 · 3 comments · Fixed by #386
Closed

Respect new lines between case statements #383

pmccloghrylaing opened this issue Jul 29, 2021 · 3 comments · Fixed by #386

Comments

@pmccloghrylaing
Copy link
Contributor

The current behaviour removes any new lines between case statements, so it converts:

switch (value)
{

    case 0:
        break;


    case 1:
        break;

}

to:

switch (value)
{
    case 0:
        break;
    case 1:
        break;
}

I think it should maintain an extra space, just like between statements in a block:

switch (value)
{
    case 0:
        break;

    case 1:
        break;
}
@belav
Copy link
Owner

belav commented Jul 30, 2021

I'm on board with this idea. I just checked prettier, and they maintain the extra line between cases statements if it exists.
I can't think of a good reason why we shouldn't do the same.

@pmccloghrylaing
Copy link
Contributor Author

.assign

@pmccloghrylaing
Copy link
Contributor Author

Should the same apply to switch expressions?
e.g.

var newState = (GetState(), action, hasKey) switch
{
    // Open/Close
    (DoorState.Closed, Action.Open, _) => DoorState.Opened,
    (DoorState.Opened, Action.Close, _) => DoorState.Closed,

    // Locking
    (DoorState.Closed, Action.Lock, true) => DoorState.Locked,
    (DoorState.Locked, Action.Unlock, true) => DoorState.Closed,

    // Do nothing
    (var state, _, _) => state
};

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

Successfully merging a pull request may close this issue.

2 participants