razor icon indicating copy to clipboard operation
razor copied to clipboard

Components that mirror HTML elements can result in bad colorization

Open NTaylorMullen opened this issue 3 years ago • 6 comments

image

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

NTaylorMullen avatar Sep 17 '21 23:09 NTaylorMullen

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 avatar Jan 11 '22 00:01 ryanbrandenburg

It's actually a bit worse than that: image Things really go off the rails if you include html after the fact there.

ryanbrandenburg avatar Jan 25 '22 00:01 ryanbrandenburg

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 avatar Jan 25 '22 18:01 ryanbrandenburg

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

ryanbrandenburg avatar Jan 25 '22 22:01 ryanbrandenburg

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.

javiercn avatar Feb 01 '22 18:02 javiercn

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

davidwengier avatar Aug 27 '23 11:08 davidwengier