razor icon indicating copy to clipboard operation
razor copied to clipboard

Blazor page formatting continually adding tabs on format/save

Open davidwengier opened this issue 3 years ago • 7 comments

Transferred from https://github.com/OmniSharp/omnisharp-vscode/issues/5394

I came across an odd bug, if I have a razor page open and press Ctrl+K, C (compare file to clipboard) the output window throws a couple errors:

[Client - 1:49:20 PM] (Warning) Failed to update the C# document buffer. This is unexpected and may result in incorrect C# interactions.

[Client - 1:49:20 PM] (Warning) Failed to update the HTML document buffer. This is unexpected and may result in incorrect HTML interactions.

I then press Ctrl+W to close the window and go back to my editor window and press Shift+Alt+F or Ctrl+S (with Format on Save enabled). Once I do that the indents just keep tabbing further and further to the right. If I close and re-open the malformed file and then press Shift+Alt+F again (or save), it fixes the formatting and does not reproduce itself unless I again use the Ctrl-K, C combo again.

Windows 10 Pro: 21H2 VSCode: 1.71.2 C# Ext : v1.25.0

davidwengier avatar Oct 27 '22 00:10 davidwengier

@allisonchou, please follow up and see if issue is fixed by your changes.

DustinCampbell avatar Oct 27 '22 21:10 DustinCampbell

This happens to me on VSCode C# extension v1.25.0. Note that this seems to happen when any "compare" window is opened. For example comparing the file with git history. In my case, once I close and re open the file it stops adding tabs, but it doesn't correct all the tabs it added previously which means I have to manually clean them up.

P.S. Is there a roadmap or release schedule for this project? I see 17.5 milestone around but I don't see how its connected to the C# extension, or .NET releases.

TrieBr avatar Nov 05 '22 18:11 TrieBr

Is there a roadmap or release schedule for this project? I see 17.5 milestone around but I don't see how its connected to the C# extension, or .NET releases.

This is something we're working on! It's a been a long while since we've pushed new Razor bits to C# for VS Code, but that's something we're actively working on. cc @allisonchou

DustinCampbell avatar Nov 10 '22 21:11 DustinCampbell

@TrieBr @mindflux We released a new version of the C# extension today (v1.25.4) which contains various Razor improvements. Would you mind trying it out and seeing if the problem still repros?

allisonchou avatar Jan 25 '23 01:01 allisonchou

https://user-images.githubusercontent.com/6871049/215977196-561b2838-265b-41a6-a862-b523dfa8211a.mov

Just saving the file multiple times.

And in the Razor log a bunch of [Client - 8:08:04 AM] (Warning) textDocument/formatting failed with TypeError: o is not iterable

Hope this helps a bit.

Edit: This is with O# 1.25.4, with the latest Razor 7.0.0 preview.

tverboon avatar Feb 01 '23 07:02 tverboon

Putting this back in triage after confirmation that it repros

davidwengier avatar Feb 07 '23 06:02 davidwengier

After reading this issue again, there might be two different issues causing the same behavior. In our case this started occurring with the O# 1.25.4 update. It's not a blazor page, but a Razor Page page and there is no need to do 'compare'. Just open the file and start saving is enough.

tverboon avatar Feb 07 '23 06:02 tverboon