-
Notifications
You must be signed in to change notification settings - Fork 352
Issue #291 better one line scope indentation #293
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
@camsteffen Can you elaborate on what this change addresses? Also you'll need to rebase if you want it merged in |
Presumably this solves the issue raised in #291:
|
@camsteffen It looks like you merged our |
Thanks for helping with the rebase. Hopefully it is set to go now. To recap the change, the regex now checks to see if there is a statement after the parenthesis for a |
I'm willing to try it out for now. We can revert if breakages come up. |
Issue #291 better one line scope indentation
hey, some things are still being indented
another example
|
Unfortunately I think we have the best solution possible using regular expressions. It becomes an ultimatum between (1) falsely indent after |
@@ -66,7 +66,7 @@ let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=] | |||
" TODO: this needs to deal with if ...: and so on | |||
let s:msl_regex = s:continuation_regex.'|'.s:expr_case | |||
|
|||
let s:one_line_scope_regex = '\%(\<\%(if\|else\|for\|while\)\>\|=>\)[^{;]*' . s:line_term | |||
let s:one_line_scope_regex = '\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(.*)\)' . s:line_term |
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.
unexpectedly this seems to be working:
let s:one_line_scope_regex = '^[})\]]*\s*\(if\|else\|while\|try\|catch\|finally\|for\|else\s\+if\)\s*_\=$'
there isn't indentation when the curly braces are omitted and the statement goes to the next line |
can you give an example? |
that other indent script correctly indents here |
Your example indents correctly for me... |
did you replace line 69 with
|
No, but now I'm confused. Why are we looking at this other line of code if it doesn't work? |
the indent script that it is copied from, jiangiao's, does correctly indent these different variations of ifs.maybe we can get a similar behavior by looking at other parts of that script to see what he did |
Sorry, it doesn't solve the problem that I described before:
Here's another way to look at it. Using regular expressions, there is no way to detect whether parenthesis are matching. It can't see if |
well, it may be possible if we try with |
Good find, I didn't know about that. Maybe I'll look into it when I have some time. It would be more than a one-liner fix. |
This is what I think would be easiest,though not elegant:
This can be extended to allow nesting more than two pairs |
last comment showed two pairs nested,here's what 4 looks like...
|
pangloss#293 this will detect the start and end parentheses,allowing statements with parentheses to come after the condition parens.This regex can detect with up to 4 levels of nesting.
No description provided.