Skip to content

Switch mechanics, indent #400

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

Merged
merged 1 commit into from
Apr 26, 2016
Merged

Switch mechanics, indent #400

merged 1 commit into from
Apr 26, 2016

Conversation

bounceme
Copy link
Collaborator

also now that I know about cindent i'm curious if there are other places like this to remove code and increase performance

@amadeus
Copy link
Collaborator

amadeus commented Apr 25, 2016

Testing this out, I am noticing some weirdness

If I just use the indentation given to me, I get this scenario:

switch (test) {
    case 1:
    test = 2;
    word = 3;
    hi = 4;
    break;
    case 2:
    weird = 2;
    hi = 3;
    break;
    default:
    test = 10;
    word = 20;
    break;
}

Yet if I try to indent the first line, 2 different things will happen:

switch (test) {
    case 1:
        test = 2; // purposely indented this line
    word = 3;
    hi = 20;
    break;
    case 2:
        hi = 2; // Purposely indented this line
        weird = 2;
        strange = 3;
        break;
    default:
        weird = 3; // Purposely indented this line
        hi = 2;
        break;
}

@bounceme
Copy link
Collaborator Author

Your example is actually broken for me too. If I understand right, this is being caused by something to do with the breaks

@bounceme
Copy link
Collaborator Author

This seems to work now and has removed even more code

@@ -475,11 +449,7 @@ function GetJavascriptIndent()

" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
if (line =~ s:expr_case)
return indent(s:GetMSL(lnum, 0)) + s:sw()/2
else
return indent(s:GetMSL(lnum, 0)) + s:sw()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⬅️ ⬅️

@davidchambers
Copy link
Collaborator

I ❤️ all the red in the diff!

also now that I know about cindent i'm curious if there are other places like this to remove code and increase performance
@bounceme
Copy link
Collaborator Author

also people could customize this in a few ways:

set cino+=:0

@amadeus
Copy link
Collaborator

amadeus commented Apr 26, 2016

Disregard my entire previously written message, I was testing on the wrong PR.

This seems to work quite well! Of course I'd like to sit on it for a couple days to make sure some other indent didn't get screwed up somehow? I only say that because I am completely ignorant of how the indent stuff works and therefore can't know if it might affect other things or not. Perhaps that's what develop is for though.

@amadeus
Copy link
Collaborator

amadeus commented Apr 26, 2016

Would you like to hold off on merging this to find some other improvements you can make? Or would prefer to file those as separate PRs?

@bounceme
Copy link
Collaborator Author

i'd prefer fixing whatever bugs come of this as they are found, which with my testing of this, isn't so worrying to prevent a merge.

@amadeus amadeus merged commit 0e7983d into develop Apr 26, 2016
@amadeus amadeus deleted the switch branch April 26, 2016 09:26
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

Successfully merging this pull request may close these issues.

3 participants