Support auto-closing quotes in Python raw string literals, etc#35636
Support auto-closing quotes in Python raw string literals, etc#35636aeschli merged 1 commit intomicrosoft:masterfrom
Conversation
Python uses a ["string prefix"](https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals) to denote bytes literals (`b''`), raw strings (`r''`), and formatted string literals (`f''`). This change makes it so that when one types `r'` in VS Code, the string will be auto-closed as `r''` (as an example). Python also supports multiple string prefixes for a single literal. I've tested that typing `fr'` will auto-close to `fr''`, and so forth.
| { "open": "f'", "close": "'", "notIn": ["string", "comment"] }, | ||
| { "open": "F'", "close": "'", "notIn": ["string", "comment"] }, | ||
| { "open": "b'", "close": "'", "notIn": ["string", "comment"] }, | ||
| { "open": "B'", "close": "'", "notIn": ["string", "comment"] } |
|
Isn't it enough to just have |
|
The original auto-close setting did not auto-close Oddly, this doesn't explain why the above configuration auto-closes |
|
Yes, there's a condition to not autoclose |
|
Sorry, this slipped. @alexandrudima Waiting for your opinion. |
|
The following added rules do nothing: Out of the added rules, this is the only one that might do something: Closing Pairs are implemented to be working on single characters. Basically, the code evaluates if someone typed the character in the |
|
@alexandrudima I tested this configuration myself when I submitted this PR. Without my changes, when you type |
|
Yes, that's what I'm saying too. The only line that makes this work from this PR is: This defines that The other 16 lines serve no purpose. |
|
@alexandrudima |
|
@Syeberman @aeschli I agree the change makes this feature work. I was quite stumped at first, since I am pretty sure how auto-closing characters should work and how they're implemented. As I thought, the execution does not enter the auto closing open character code (since that is implemented to only work on single characters), but it enters @aeschli Since this is something you've authored in ebc3074 , I cannot be of further assistance. Perhaps now would be a good time to document somewhere this behaviour! |
|
Talked to @alexandrudima again and we are fine with the PR. Not autoclosing Thanks @Syeberman! |
|
I still have the issue on |
|
@diazgilberto Please file a new issue with a code sample that shows the problem. Also try to run without extensions to see whether an external extension causes this. |
Python uses a "string prefix" to denote bytes literals (
b''), raw strings (r''), and formatted string literals (f''). This change makes it so that when one typesr'in VS Code, the string will be auto-closed asr''(as an example).Python also supports multiple string prefixes for a single literal. I've tested that typing
fr'will auto-close tofr'', and so forth.