Fix close tag completion replacement ranges - #85710
Open
davidwengier wants to merge 1 commit into
Open
davidwengier wants to merge 1 commit into
davidwengier wants to merge 1 commit into
Conversation
Don't use the full recovered end tag span when the close angle is missing, since it can include following Razor and C# content.
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is small, targeted, and includes a regression test that exercises the new replacement-range behavior in a realistic nested Razor/C# scenario.
Review effort: Lite
Findings: None
What changed in this PR
This PR adjusts Razor HTML close-tag completion’s replacement range to avoid deleting unrelated following content when the Razor parser’s error recovery produces an overly-large end-tag span.
Changes:
- Narrow the close-tag
TextEditreplacement range to end at the end-tag name when the close-angle token is missing, otherwise end at the close-angle token. - Add a regression test covering close-tag completion inside nested C# blocks to ensure following code is preserved.
| File | Description |
|---|---|
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/Html/LocalHtmlCompletionProvider.cs | Constrains close-tag completion replacement ranges to avoid consuming error-recovered trailing content. |
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Remote.Razor.UnitTests/Completion/LocalHtmlCompletionProviderTest.cs | Adds regression coverage ensuring close-tag completion doesn’t remove subsequent Razor/C# content. |
Member
Author
|
Ping @dotnet/roslyn-ide @dotnet/razor-tooling for review |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stop end-tag completion from eating the rest of the Razor document due to poor error recovery in the compiler.
Fixes #85709
Microsoft Reviewers: Open in CodeFlow