Skip to content

Formatting .razor files #8649

@klukc7

Description

@klukc7

error.txt

I get an error when trying to format larger .razor file.

2025-09-24 14:51:54.133 [error] [Formatting.New.CSharpFormattingPass] Ran out of lines while trying to process formatted changes. Abandoning further formatting to not corrupt the source file, please report this issue.
[Formatting.New.CSharpFormattingPass] Ran out of lines while trying to process formatted changes. Abandoning further formatting to not corrupt the source file, please report this issue.
Stack Trace:
Error: [Formatting.New.CSharpFormattingPass] Ran out of lines while trying to process formatted changes. Abandoning further formatting to not corrupt the source file, please report this issue.
at jE.log (c:\Users\lukkur.vscode\extensions\ms-dotnettools.csharp-2.90.60-win32-x64\dist\extension.js:1203:18866)
at c:\Users\lukkur.vscode\extensions\ms-dotnettools.csharp-2.90.60-win32-x64\dist\extension.js:1208:34315
at hr (c:\Users\lukkur.vscode\extensions\ms-dotnettools.csharp-2.90.60-win32-x64\dist\extension.js:46:1620)
at Ar (c:\Users\lukkur.vscode\extensions\ms-dotnettools.csharp-2.90.60-win32-x64\dist\extension.js:45:7629)
at Immediate.onImmediate (c:\Users\lukkur.vscode\extensions\ms-dotnettools.csharp-2.90.60-win32-x64\dist\extension.js:45:7324)
at processImmediate (node:internal/timers:485:21)
2025-09-24 14:51:54.135 [error] [textDocument/formatting] [LSP] System.ArgumentException: The changes must not overlap. (Parameter 'changes')
at Microsoft.CodeAnalysis.Text.SourceText.WithChanges(IEnumerable1 changes) in /_/src/Compilers/Core/Portable/Text/SourceText.cs:line 791 at Microsoft.CodeAnalysis.Text.ChangedText.WithChanges(IEnumerable1 changes) in /
/src/Compilers/Core/Portable/Text/ChangedText.cs:line 157
at Microsoft.CodeAnalysis.Razor.Formatting.New.CSharpFormattingPass.ExecuteAsync(FormattingContext context, ImmutableArray1 changes, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Razor.Formatting.RazorFormattingService.GetDocumentFormattingChangesAsync(DocumentContext documentContext, ImmutableArray1 htmlChanges, Nullable1 range, RazorFormattingOptions options, CancellationToken cancellationToken) at Microsoft.VisualStudioCode.RazorExtension.Services.VSCodeRemoteServiceInvoker.TryInvokeAsync[TService,TResult](Solution solution, Func4 invocation, CancellationToken cancellationToken, String callerFilePath, String callerMemberName)
at Microsoft.VisualStudio.Razor.LanguageClient.Cohost.CohostDocumentFormattingEndpoint.HandleRequestAsync(DocumentFormattingParams request, TextDocument razorDocument, RazorCSharpSyntaxFormattingOptions csharpSyntaxFormattingOptions, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions