Skip to content

Don't show error bars during format on paste#12806

Merged
davidwengier merged 5 commits intodotnet:mainfrom
davidwengier:RangeFormatting
Feb 23, 2026
Merged

Don't show error bars during format on paste#12806
davidwengier merged 5 commits intodotnet:mainfrom
davidwengier:RangeFormatting

Conversation

@davidwengier
Copy link
Copy Markdown
Member

Fixes #12805

The paste here leaves the document with multiple syntax errors which the Razor parser doesn't do a great job with (Html document ends up with close braces, C# document ends up with div tags) which makes formatting throw up. We already have code that skips range formatting if there are Razor diagnostics, but in this case there are only C# diagnostics, and it's too expensive to query them, especially during typing.

@davidwengier davidwengier requested a review from a team as a code owner February 20, 2026 11:54
return await _formattingService.GetDocumentFormattingChangesAsync(context, htmlChanges, linePositionSpan, options, cancellationToken).ConfigureAwait(false);
}
catch (Exception) when (options.FromPaste)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these logged inside the formatting service at least? And if so, do we want the formatting service to know that it came from paste so we can see that in the logs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the errors messages are logged by the formatting logger, and its the logger in OOP that catches the error being logged, and throws the exception to trigger the info bar, which is what we're swallowing here. The full options object is also logged, so we'll know from now on whether the format operation is from a paste. To actually solve this issue, I had to basically guess :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Razor on MAUI Blazor for Andorid, iOS

3 participants