-
Notifications
You must be signed in to change notification settings - Fork 352
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
Conversation
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;
} |
Your example is actually broken for me too. If I understand right, this is being caused by something to do with the breaks |
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⬅️ ⬅️
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
also people could customize this in a few ways:
|
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 |
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? |
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. |
also now that I know about cindent i'm curious if there are other places like this to remove code and increase performance