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
505 stars 195 forks source link

Components that mirror HTML elements can result in bad colorization #4533

Open NTaylorMullen opened 3 years ago

NTaylorMullen commented 3 years ago

image

The end </Input> tag should be colored. I half wonder if this is a compiler issue but we should investigate nevertheless.

ryanbrandenburg commented 2 years ago

Likely problem spot: https://github.com/dotnet/razor-tooling/blob/main/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/TagHelperSemanticRangeVisitor.cs#L406-L420

Edit: This is not the problem.

ryanbrandenburg commented 2 years ago

It's actually a bit worse than that:

image

Things really go off the rails if you include html after the fact there.

ryanbrandenburg commented 2 years ago

Looking at the syntax tree here we have another instance of a SyntaxTree which is shorter than the document. Seemingly something about the self-closing <input /> confuses the parent causing the closing </Input> to be omitted from the SyntaxTree entirely. This seems to happen during one of the post-parse phases, though I haven't identified which one. CC @TanayParikh.

ryanbrandenburg commented 2 years ago

https://github.com/dotnet/aspnetcore/issues/39764

javiercn commented 2 years ago

I think this one is trickier since we do have general issues around creating components that "match" the syntax of a valid HTML elements. I need to check with the team what our actual thoughts on this specific case are.

davidwengier commented 1 year ago

Possibly the same root cause as https://github.com/dotnet/razor/issues/8460