microsoft / vscode-html-languageservice

Language services for HTML
MIT License
220 stars 109 forks source link

Razor formatting issue with the at sign (@) #179

Closed vudzero closed 6 months ago

vudzero commented 6 months ago

Hi,

Not sure if it's the right place but I have an issue with the html formatting of razor code. The html fortmatter does not seems to handle at signs (@) properly when used as a prefix of an attribute name.

What is expected

image

What I get after formatting

image

I'm using the "html.format.wrapAttributes": "force-expand-multiline", options

I'm willing to investigate if someone can point me where to look at

Thanks!

aeschli commented 6 months ago

The HTML language server is intended for HTML. It can work for HTML templating languages, but there's no guarantee for it. We use beautifyjs as the underlying HTML formatter. You can try to file the issue there.

vudzero commented 6 months ago

Thanks for your answer!

Would you happen to know why it does work in the beautifyjs playground but not un VSCode?

image

image

aeschli commented 6 months ago

I see you are in a Razor file. Is the editor language mode Razor? You can see that in the status bar.

In my reply I assumed the editor was in HTML mode.

Out-of-the box, VS Code does not provide a formatter for Razor files. It comes from an extension. You have to file the issue against that extension. https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp is the extension that also covers Razor.