-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Backticks not auto-closing for tagged template literals #61070
Comments
(Experimental duplicate detection) |
It seems to me the editor only adds backtick if it's legal for a template string to be in that place. However your example is only legal if styled components are allowed. Could you give an example with a valid js syntax? If it only happens with styled component syntax, could be it's a bug (or a lack of feature) in the styled component extension. |
It works with just plain ES6 syntax as well. This example:
Is valid ES6, no React/styled-components, and the same issue occurs when trying to type the multi-line literal. I should note that manually closing the literal on the same line does work okay, although it doesn't auto-close. It is only on multi-line template literals that the auto-close fires on the last tick. |
I'm seeing this bug also in python, where backticks have no special meaning 😞. Sometimes I use them to denote arguments in a user string: raise ValueError(f'No XML documents found in `{xml_dir}`) But when I type the second backtick, vscode inserts two, resulting in: Strangely, this only happens if there is @mjbvz should I open a different issue with this problem, to be tagged as a bug? If so, does it belong here or to |
@mjbvz Can this be added for this iteration? |
As a workaround, set: "editor.autoClosingQuotes": "always" Opened #71970 to track possible solution |
Thanks for that! |
FWIW, I found disabling the Babel JavaScript extension put a stop to doubling up on backticks when closing a pair. (However as I rely on that extension, disabling it isn't really an option.) |
Issue Type: Bug
When working with tagged template literals in JS and JSX (styled-components is my use case), the backticks used to auto-close when typed, but that recently changed. The big issue though is that if you go into a multi-line literal, and then try to type the closing backtick, vscode inserts two backticks, leaving you with three.
For example if I type:
I would expect to have the closing tick automatically inserted and the cursor in between them. Instead it just stops there. If I then go on to enter some css and then manually enter the closing backtick, I get:
I then have to manually delete the third backtick, as if I delete the second, the whole pair is deleted because of the auto-close rules.
I have verified this is happening on Mac and Windows 10, with extensions enabled and disabled, and in the Insiders build.
VS Code version: Code 1.28.1 (3368db6, 2018-10-11T18:07:48.477Z)
OS version: Darwin x64 18.0.0
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Extensions (20)
(3 theme extensions excluded)
The text was updated successfully, but these errors were encountered: