dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

saving razor file display endless message "Saving...: Running c# formatter" #4147

Open ponchautf opened 4 years ago

ponchautf commented 4 years ago

Issue Description

When working with razor files, saving a file don't work. "Sometime" a message is displayed at the bottom of the screen Screen Cast 2020-10-25 at 4 53 10 PM

I have to manually close the message and save again. this only work 1 time, on next time I save, the message is displayed again, need to close, save again, ....

Steps to Reproduce

Not sure... work on .razor file, save it, work, save, and a a certain point this message is displayed.

Expected Behavior

The file is saved without displaying message

Actual Behavior

A message block the save operation

Logs

OmniSharp log

Nothing special [info]: OmniSharp.OmniSharpWorkspace Miscellaneous file: /Users/xxxx/Projets/xxxx/xxxx.Application/obj/Debug/netcoreapp3.1/Razor/Views/_ViewImports.cshtml.g.cs added to workspace [info]: OmniSharp.OmniSharpWorkspace Miscellaneous file: /Users/xxxx/Projets/xxx/xxxx.Application/obj/Debug/netcoreapp3.1/Razor/Views/_ViewStart.cshtml.g.cs added to workspace [info]: OmniSharp.OmniSharpWorkspace Miscellaneous file: /Users/xxxx/Projets/xxxx/xxxx.Application/obj/Debug/netcoreapp3.1/Razor/Views/Customer/Edit.cshtml.g.cs added to workspace

C# log

Nothing, the c# output is empty

Environment information

VSCode version: 1.50.1 C# Extension: 1.23.4

Mono Information OmniSharp using global mono :6.12.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.402 Commit: 9b5de826fd Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.402/ Host (useful for support): Version: 3.1.8 Commit: 9c1330dedd .NET Core SDKs installed: 3.0.100 [/usr/local/share/dotnet/sdk] 3.1.100 [/usr/local/share/dotnet/sdk] 3.1.101 [/usr/local/share/dotnet/sdk] 3.1.200 [/usr/local/share/dotnet/sdk] 3.1.300 [/usr/local/share/dotnet/sdk] 3.1.402 [/usr/local/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |asp-net-core-switcher|adrianwilczynski|2.0.2| |auto-close-tag|formulahendry|0.5.9| |auto-rename-tag|formulahendry|0.1.5| |azure-account|ms-vscode|0.9.3| |csharp|ms-dotnettools|1.23.4| |docomment|k--kato|0.1.18| |flow-for-vscode|flowtype|1.5.0| |LiveServer|ritwickdey|5.6.1| |mssql|ms-mssql|1.9.0| |open-in-browser|techer|2.0.0| |path-intellisense|christian-kohler|2.3.0| |todo-tree|Gruntfuggly|0.0.183| |vscode-colorize|kamikillerto|0.8.17| |vscode-counter|uctakeoff|2.2.0| |vscode-docker|ms-azuretools|1.7.0| |vscode-eslint|dbaeumer|2.1.13| |vscode-html-css|ecmel|0.2.3| |vscode-icon-theme|jtlowe|1.6.6| |vscode-react-native|msjsdiag|1.1.0| |vscodeintellicode|VisualStudioExptTeam|1.2.10|;

Environment data

dotnet --info output: VS Code version: C# Extension version:

OmniSharp log

Steps to reproduce

Expected behavior

Actual behavior

filipw commented 4 years ago

does this reproduce with other extensions disabled? previously when similar problems were reported, it turned out that it was caused by the doccomment extension.

amartens181 commented 3 years ago

I've had the same issue after creating a razor component. Restarting Code did not fix it the first time; after a few restarts, it fixed itself and could format the code.

[Error - 2:28:41 PM] Request textDocument/formatting failed.
  Message: Internal Error - System.ArgumentException: The changes must not overlap. (Parameter 'changes')
   at Microsoft.CodeAnalysis.Text.SourceText.WithChanges(IEnumerable`1 changes)
   at Microsoft.AspNetCore.Razor.LanguageServer.Formatting.FormattingPassBase.NormalizeTextEdits(SourceText originalText, TextEdit[] edits) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/FormattingPassBase.cs:line 125
   at Microsoft.AspNetCore.Razor.LanguageServer.Formatting.HtmlFormattingPass.ExecuteAsync(FormattingContext context, FormattingResult result, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/HtmlFormattingPass.cs:line 54
   at Microsoft.AspNetCore.Razor.LanguageServer.Formatting.DefaultRazorFormattingService.FormatAsync(DocumentUri uri, DocumentSnapshot documentSnapshot, Range range, FormattingOptions options, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DefaultRazorFormattingService.cs:line 73
   at Microsoft.AspNetCore.Razor.LanguageServer.Formatting.RazorFormattingEndpoint.Handle(DocumentFormattingParams request, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/RazorFormattingEndpoint.cs:line 112
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|5_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass38_0.<<RouteRequest>b__5>d.MoveNext()
  Code: -32603