dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
485 stars 190 forks source link

Bug: VS 2022 cshtml file breaks javascript formatting #9645

Open vsfeedback opened 8 months ago

vsfeedback commented 8 months ago

This issue has been moved from a ticket on Developer Community.


[severity:It’s more difficult to complete my work] [regression] [worked-in:VS 2019]
Javascript usually has nicely coloured fonts for reserved words and strings. But if the html code above the js has an html style comment starting with <!-- inside a cs block (which starts with the @ symbol) then the formatting is lost.

<!-- This comment is fine  -->
@if (1 == 1)
{
    // This comment works fine here
    <!-- But this one breaks the javascript highlighting below just by existing inside the if loop -->
    <h3 class="page-title" id="PageTitle"><b><u>Blah blah</u></b></h3>
}

<script>
    var loading = true;
    // blah
</script>

Original Comments

Feedback Bot on 8/28/2023, 06:30 PM:

(private comment, text removed)

Feedback Bot on 9/5/2023, 03:32 AM:

(private comment, text removed)


Original Solutions

(no solutions)

chsienki commented 8 months ago

@davidwengier @333fred Is this likely to be a parsing issue? That the compiler is incorrectly reporting the tree and the tooling is thus doing the wrong thing?

davidwengier commented 8 months ago

This would most likrly be a TextMate grammar issue, not compiler.

howing0345 commented 3 months ago

VS Code also has this issue too.