Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Don't de-indent case and default statements #36

Merged
merged 1 commit into from
Jun 26, 2014

Conversation

yeldarby
Copy link
Contributor

This commit changes the formatting of a switch statement from

switch(x) {
case 1:
    //stuff
case 2:
    //stuff
default:
    //stuff
}

to

switch(x) {
    case 1:
        //stuff
    case 2:
        //stuff
    default:
        //stuff
}

Note the indentation is not decreased for case and default statements.

I know others will likely disagree with this style preference but I couldn't figure out how to control this at runtime in my init script or keymap file.

Is there a way to add this change at runtime or add a preference so I wouldn't have to maintain a fork and keep it up to date with upstream changes?

@izuzak
Copy link
Contributor

izuzak commented Jun 25, 2014

I know others will likely disagree with this style preference but I couldn't figure out how to control this at runtime in my init script or keymap file.

Personally, I like the "classic" indentation behavior suggested in this PR as well 👍. Also, I've checked a few "major" JavaScript projects and those seem to use this way of indenting case as well.

(It seems that the current style of indenting case statements comes from [Crockford](http://javascript.crockford.com/code.html#switch statement): "Each case is aligned with the switch. This avoids over-indentation. A case label is not a statement, and should not be indented like one.")

Also, this fixes #33 I believe.

cc @probablycorey @kevinsawicki

@probablycorey probablycorey self-assigned this Jun 26, 2014
@probablycorey
Copy link

Well, that makes three of us that don't like case and default indented! Thanks, @yeldarby!

probablycorey pushed a commit that referenced this pull request Jun 26, 2014
Don't de-indent case and default statements
@probablycorey probablycorey merged commit 8132960 into atom:master Jun 26, 2014
drewctaylor pushed a commit to drewctaylor/multiverse-syntax that referenced this pull request May 10, 2015
Don't de-indent case and default statements
@kyriacos
Copy link

I know this is closed, just wondering if there a setting to modify it so existing projects that have been using the previous way don't have to reformat?

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

Successfully merging this pull request may close these issues.

4 participants