razor icon indicating copy to clipboard operation
razor copied to clipboard

Auto-closing void elements in C# blocks does not work as epected

Open NTaylorMullen opened this issue 3 years ago • 2 comments

OUTLOOK_w7YBJwDWF9

Note: This looks like a 17.3 regression

NTaylorMullen avatar May 18 '22 18:05 NTaylorMullen

Adding some variations that seem like same issue? 2022-05-18_11-24-23

timheuer avatar May 18 '22 18:05 timheuer

@timheuer ya that one about div is a Razor compiler issue surprisingly: https://github.com/dotnet/razor-tooling/issues/7608

Gist is that the compiler is matching your outer div with the nested one even though it's wrapped in a C# block

NTaylorMullen avatar May 18 '22 18:05 NTaylorMullen

The issue here is in the AutoClosingTagOnAutoInsertProvider but the root cause is we're getting back odd answers when we ask the compiler for the owner of the position in the document. Perhaps we could experiment with asking for the owner at the position before the close angle, as I believe we currently ask for the position after. Not sure what would break here though, so I would recommend time-boxing this one. We can revisit after the compiler fixes the ownership system, which is on the cards.

davidwengier avatar Mar 08 '23 00:03 davidwengier

This doesn't repro any more, probably fixed by https://github.com/dotnet/razor/pull/8979 since that was the intent of the new API 😁

davidwengier avatar Aug 27 '23 11:08 davidwengier