sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
714 stars 95 forks source link

Strange issue in vscode when pasting #427

Open alancwoo opened 4 months ago

alancwoo commented 4 months ago

I'm not sure if this is the correct place to post this, but I'm having an issue with:

VSCode 1.86.1 Prettier Extension v10.1.0 Svelte for VS Code v108.2.2

If I paste anything in a document, the entire script tag is immediately replaced by a base64 encoding of its contents:

https://github.com/sveltejs/prettier-plugin-svelte/assets/1481890/f75bec4b-88b6-42c7-a76c-5d01a187b97a

My .prettierrc is as follows:

{
  "useTabs": false,
  "tabWidth": 2,
  "singleQuote": true,
  "trailingComma": "none",
  "printWidth": 100,
  "plugins": ["prettier-plugin-svelte"],
  "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

This only happens in .svelte files, and only when "plugins": ["prettier-plugin-svelte"] is set in .prettierrc

alancwoo commented 4 months ago

Sorry I found an old issue here: https://github.com/sveltejs/prettier-plugin-svelte/issues/240 which is closed, so I can indeed confirm this is still happening.

alancwoo commented 4 months ago

If I set editor.formatOnSave to false, then this no longer happens. I'm actually not sure why I had that enabled, but in any case it should not be happening regardless.

dummdidumm commented 4 months ago

Maybe you're running into #233 Also, which extension is responsible for formatting the code? The Svelte extension or the Prettier extension (you can see that in your VS Code config)? Also make sure that you have the latest version of prettier and prettier-plugin-svelte in your package.json. If this still persists, we need a proper reproduction.