language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Formatter removes comments in specific contexts

Open lemonlime4 opened this issue 1 month ago • 1 comments

Describe the bug

The following comments get deleted.

<p /* a > b , c */ ></p>
<br /* a > b , c */ />

Reproduction

Put the above code in a .svelte file and format the document using Prettier

Expected behaviour

Comments shouldn't disappear

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

lemonlime4 avatar Oct 21 '26 13:10 lemonlime4

This comes from prettier-plugin-svelte: comments in an opening tag without attributes are never attached, and a > inside a comment ends the tag-range scan too early. I opened a fix in sveltejs/prettier-plugin-svelte#551.

MFA-G avatar Oct 21 '26 13:10 MFA-G