Skip to content

Generate Documentation - incorrect buffer bug - #84709

Merged
akhera99 merged 2 commits into
dotnet:mainfrom
akhera99:fix_gen_docs_bug
Jul 31, 2026
Merged

Generate Documentation - incorrect buffer bug#84709
akhera99 merged 2 commits into
dotnet:mainfrom
akhera99:fix_gen_docs_bug

Conversation

@akhera99

@akhera99 akhera99 commented Jul 30, 2026

Copy link
Copy Markdown
Member

ApplyDocumentationEditsAsync is invoked with textView.TextBuffer, but the edit spans are based on the snapshot passed in (captured from the subject buffer in the command handler). In projection scenarios these buffers can differ, and translating spans across snapshots from different buffers will fail. Use the buffer associated with the captured snapshot when applying edits.

Microsoft Reviewers: Open in CodeFlow

akhera99 and others added 2 commits July 30, 2026 14:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 30, 2026 21:43
@akhera99
akhera99 requested a review from a team as a code owner July 30, 2026 21:43
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a buffer-mismatch bug in the Copilot “Generate Documentation” flow by ensuring documentation edits are applied to the same ITextBuffer that the captured ITextSnapshot came from, avoiding span translation failures in projection-buffer scenarios.

Changes:

  • Remove the ITextView parameter from GenerateAndApplyDocumentationAsync since it’s no longer needed for applying edits.
  • Apply generated documentation edits using snapshot.TextBuffer instead of textView.TextBuffer to keep span translation within the same buffer.
Show a summary per file
File Description
src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs Applies documentation edits to the snapshot’s buffer to prevent cross-buffer span translation failures (notably in projection scenarios).

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

@akhera99
akhera99 merged commit afda669 into dotnet:main Jul 31, 2026
27 checks passed
@jjonescz jjonescz added this to the 18.11 milestone Aug 25, 2026
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.

4 participants