Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sort Usings in Inline Diff #74645

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

KirillOsenkov
Copy link
Member

Invoking Sort Usings on an added using directive while in diff mode was throwing an ArgumentException because textView.GetTextElementSpan() expects to be passed a SnapshotPoint on the top (projection) buffer, not the subject buffer.

Since the snapshotSpan is only needed for the indicatorFactory and it needs to be in the top buffer, pass the caret position in the top buffer instead.

Instead of passing the snapshotSpan.Snapshot to getCurrentDocumentAsync later (which requires the subject buffer), use the buffer from the caretPoint we grabbed earlier, which is in the subject buffer.

Verified that it fixes sort usings in diff.

Fixes #74594

Invoking Sort Usings on an added using directive while in diff mode was throwing an ArgumentException because textView.GetTextElementSpan() expects to be passed a SnapshotPoint on the top (projection) buffer, not the subject buffer.

Since the snapshotSpan is only needed for the indicatorFactory and it needs to be in the top buffer, pass the caret position in the top buffer instead.

Instead of passing the snapshotSpan.Snapshot to getCurrentDocumentAsync later (which requires the subject buffer), use the buffer from the caretPoint we grabbed earlier, which is in the subject buffer.

Verified that it fixes sort usings in diff.

Fixes dotnet#74594
@JoeRobich
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@CyrusNajmabadi CyrusNajmabadi merged commit f20e4d3 into dotnet:main Nov 26, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 26, 2024
@KirillOsenkov KirillOsenkov deleted the dev/kirillo/fix74594 branch November 26, 2024 04:01
@dibarbet dibarbet modified the milestones: Next, 17.13 P3 Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
4 participants