Repository navigation
Fix close tag completion replacement ranges - #85710
davidwengier merged 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. |
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. |
|
Ping @dotnet/roslyn-ide @dotnet/razor-tooling for review |
chsienki
left a comment
There was a problem hiding this comment.
This seems fine as a targeted fix, but presumably the better fix is to handle error recovery in the compiler better? We should perhaps put an issue link here so we'll find the workaround if we ever get to real error recovery.
|
I don't disagree, but I hate that adding a comment needs me to wait for approvals again, so I'm going to just have faith that the LLMs will find this :P |
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