'Visual Studio 2022 - Razor view is not formatting correctly

When I open a .cshtml file in VS2022 that has nested taghelpers in it, the formatting for that file doesn't work and I get the following errors spewed out into the Output for the Razor Language Server Client.

Warning: OmniSharp.Extensions.LanguageServer.Server.Configuration.DidChangeConfigurationProvider: No ConfigurationItems have been defined, configuration won't surface any configuration from the client! | 
Error: Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService: Error thrown while retrieving CSharp semantic range - OmniSharp.Extensions.JsonRpc.Server.JsonRpcException: 'end' must not be less than 'start'
Parameter name: end
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.JsonRpc.ResponseRouter.ResponseRouterReturnsImpl.<Returning>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetMatchingCSharpResponseAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetCSharpSemanticRangesAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.DefaultRazorSemanticTokensInfoService.<GetSemanticTokensAsync>d__10.MoveNext() |

Once I start to type in new html elements, intellisense works, but the attributes are plain black. I found something about it here: https://developercommunity.visualstudio.com/t/vs-2022-razor-editor-not-formatting-html/1625350

The nested taghelper is a kendo-grid. I have raised a ticket with the developers and they are unable to reproduce it.

Has anyone had something similar to this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source