-
Notifications
You must be signed in to change notification settings - Fork 1.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
Incorrect indentation after string literals containing escaped characters #4241
Comments
I am not familiar with the code, but it may be this string: |
Yeah, this is really annoying. It seems like this was introduced by the "fix" for #3284. If I had to choose between having line continuation backslashes work properly, or backslash escapes work properly, I would choose backslash escapes in a heartbeat. Some people probably never use backslash for line continuation, while most other people probably use it very sparingly, since PEP 8 encourages implicit line continuation wherever it can be sensibly applied. And even if you like backslash line continuation, (1) presumably you're not going to have large sections of code riddled with them, since long lines are discouraged anyway, and (2) you have reasonable alternatives for achieving what you need. Whereas there are plenty of situations where you could be using a lot of backslash escapes (strings, regular expressions), and there is no reasonable alternative. |
I'm pretty sure you've hit the nail on the head. It seems like such a simple and easy fix (see my comment on #5821, which perhaps should gave gone on #3915). If we are wrong about this, and it's actually more complicated, then I wish they would come out and explain why. |
Prescribed Solution:
There may be a more correct regex to use:
See #5821 (comment). Make sure this does not break the following (from #3284): a = 1 + \
<--- indent is here |
I've verified that the following indent/dedent properly: a = '\n'
# cursor here
a = 1 + \
# cursor here |
* Dedent on elif|else * Add unit tests (will conflict with #4241) * More descriptive comment (same as f5daf78) * Move tests from extension to language config file * Add news file * Use regex we just introduced * Space is free * Update regexes and existing tests (so they pass) * Add support for open tuples and dictionaries * Shuffle and add tests * Typo + more descriptive key name * Updated news file after new changes * Apply suggestions from code review (first batch) Co-Authored-By: Eric Snow <[email protected]> * Update src/client/language/languageConfiguration.ts Co-Authored-By: Eric Snow <[email protected]> * Third batch of review fixes * Add some comments * Separate unit tests * More test simplification * Simplify return regex * Remove unnecessary tslint disable rule * pipeline is stuck
Steps to reproduce:
Same for double quotes.
Expected behaviour
Actual behaviour
Environment data
Logs
Console:
The text was updated successfully, but these errors were encountered: