-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Addresses single line if/for/while/etc indentation #115454
Conversation
Not sure if this is known and covered by the TODO, but I noticed some weird behavior after the first single line indent (and seems to also happen with multiline). Watch this: |
@Devyre Good catch, I didn't notice it before. Let me know if it works this time. |
As far as I can tell, for the purposes of this PR, That leaves |
As for implementing indentation tests for other base language extensions, I'd probably have to modify the Besides that though, I think it's somewhat ready for review now. |
One more thing I should point out is that One way to solve this might be to unify |
I'm not sure if we want to invest more in textmate indentation rules at this moment. I'm leaning towards no so closing this for now. Thank you for your contribution! If we think it's wroth exploring, we can still take this in in the future, but I'll leave this decision to @aiday-mar. |
Resolves #43244
This PR adds/changes indentation rules for languages with C-like single line control statements. While the majority of these changes can be implemented through the existing
language-configuration.json
options, there are some extra changes to the codebase that needs to be done.So far, this PR implements the majority of these changes for C/C++, C#, Java, TS/JS/TSX/JSX, Objective C/C++, and PHP. JavaScript is shown below for example.
However, there was a notable problem with the new indentation rules in that the following would break. (
^
represents the cursor)Before:
After:
To fix that, I added a new indentation rule to capture the previous line as well (so it can be taken into context).
Using this new rule restricts the unindent to more specific cases.
If
decreaseIndentPattern
was used instead:Although it works, it's not as elegant as before. This is what the end result should look like.
Update: This part is working now!
To-Do
onEnterRule
)decreaseIndentWithPreviousLinePattern
itself worksdecreaseIndentWithPreviousLinePattern
doesn't affect a control statement where the previous line is just whitespace