Skip to content
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

CSS tagged template literals don't self close #36

Closed
ferdaber opened this issue Sep 13, 2018 · 5 comments
Closed

CSS tagged template literals don't self close #36

ferdaber opened this issue Sep 13, 2018 · 5 comments

Comments

@ferdaber
Copy link

ferdaber commented Sep 13, 2018

Before VS Code v1.27, the following would happen when creating a CSS tagged template literal (note that this issue happens with styled components, or any tagged template literal function name that triggers CSS highlighting):

const foo = css
// press the tickmark (`) key
const foo = css`|` // cursor is in the middle of two tickmarks, and the literal is self-closing

Now, this is what happens:

const foo = css
// press the tickmark (`) key
const foo = css`| // cursor is after the first tickmark, and it is not self closing
// press the tickmark (`) key to close the literal
const foo = css``|` // two tickmarks are inserted and the cursor is after the second one

I can confirm that this does not happen with any other names, for example this still works:

const foo = html
// press the tickmark (`) key
const foo = html`|` // cursor is in the middle of two tickmarks, and the literal is self-closing

I'm not sure where to file this issue, I would think that it's related to the CSS language detection part of the plugin, but I can confirm that it only happens with CSS-highlighted tagged template literals, and also only when this plugin is enabled.

@ankithkonda
Copy link

Can confirm, I though it was the styled components extension, but after messing around with extensions a bit more, the problem is with vscode-language-babel. e.g. -

When you type in the templet literal quote marks, it adds 1 but doesn't seem to recognise it, and then when you try and complete it, vscode adds one more at the end, so you end up with 3

sep-21-2018 10-52-53

VSCode: 1.27.2
vscode-styled-components: 0.0.21

package.json -

"polished": "^1.9.3",
"styled-components": "^3.4.2"

VSCode settings:

{
  "terminal.integrated.shell.osx": "/bin/zsh",
  "terminal.integrated.fontFamily": "Roboto mono for Powerline",
  "workbench.iconTheme": "vscode-icons",
  "editor.renderIndentGuides": false,
  "guides.enabled": false,
  "gitlens.keymap": "alternate",
  "gitlens.advanced.messages": {
    "suppressShowKeyBindingsNotice": true
  },
  "window.zoomLevel": 1,
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false
  },
  "eslint.autoFixOnSave": true,
  "eslint.alwaysShowStatus": true,
  "editor.minimap.enabled": false,
  "window.title": "",
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.php$",
        "cmd": "prettier ${file} --write"
      }
    ]
  }
}

@michaelgmcd
Copy link
Owner

Sorry for the delay, I've been away for the past couple of weeks. I will hopefully be able to take a look this weekend.

@michaelgmcd
Copy link
Owner

This appears to be an issue in VSCode itself. I'll keep track of this and update accordingly.
microsoft/vscode#61070

@michaelgmcd
Copy link
Owner

I haven't tried this myself, but it seems that setting "editor.autoClosingQuotes": "always" is a workaround for this issue

@michaelgmcd
Copy link
Owner

Closing this since there is a decent workaround and vscode's fix should suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants