Visual Studio 2022 V 17.9.0 Preview 2 Inserts Lines after @ in Blazor Server App
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] While editing a . Razor component that has similar code to the following:
<td align="right">@li.Qty.ToString("0.00")</td>
<td align="right">@li.Rate.ToString("$0.00")</td>
<td align="right">@(li.Disc * 100)%</td>
if in the @code section you create a new function:
private void MyFunc()
{}
when you press enter in between the {} to insert your code, it wreaks havoc on the blazor code above that has the @. It changes it to:
<td align="right">@
li.Rate.ToString("
.00")
</td>
thus creating errors in your code as shown on image:

In order to temporarily correct the situation, immediately after the error occurs, you can press Ctrl-Z to undo only ONCE and it will allow you to continue. More of an annoyance than a bug. I assume it must be related to the new Razor intellisense/handling, but I am not sure.
Original Comments
Feedback Bot on 12/13/2023, 05:19 PM:
(private comment, text removed)
Mariano J. Padilla on 12/14/2023, 07:30 AM:
(private comment, text removed)
Feedback Bot on 1/31/2024, 04:50 PM:
(private comment, text removed)
Original Solutions
(no solutions)
The $0 seems to be what is triggering the bug. I was able to reproduce this error consistently on visual studio. When I hit"Enter" on the keyboard, auto-format does its job and the position of the cursor and the $0 get flipped.
https://github.com/dotnet/razor/assets/17770319/609191ce-09da-4da3-895a-8eb5b15c6c1c