git_ui: Fix multibuffer coordinate conversion in clipboard diff#51985
Merged
Veykril merged 2 commits intozed-industries:mainfrom Mar 20, 2026
Merged
Conversation
auto-merge was automatically disabled
March 20, 2026 07:00
Head branch was pushed to by a user without write access
Contributor
Author
|
@Veykril can you approve again, please sorry forgot the fmt again ! Thanks |
Contributor
Author
Happy to contribute |
3 tasks
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 20, 2026
…industries#51985) ## Context Fixes the visual selection update in `TextDiffView::open` to properly convert between buffer-local and multibuffer coordinates using `buffer_point_to_anchor`. Previously, raw multibuffer Points were used directly for line expansion, which produced incorrect regions when expanded deleted diff hunks shifted multibuffer row numbers. This provides a single unified code path for both singleton and non-singleton multibuffers, as suggested in [zed-industries#51457 review feedback](zed-industries#51457 (comment)). Follow-up to zed-industries#51457. ## How to Review Small PR - all changes are in `crates/git_ui/src/text_diff_view.rs`. Focus on: - `open()`: The visual selection update block now uses `buffer_point_to_anchor` + `to_point` instead of raw multibuffer coordinate math - No more assumption that multibuffer Points == buffer-local Points - Existing tests validate both singleton and non-singleton multibuffer paths ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] The content is consistent with the UI/UX checklist - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed incorrect diff region when using "Diff Clipboard with Selection" with expanded diff hunks in the editor.
toshmukhamedov
pushed a commit
to toshmukhamedov/zed
that referenced
this pull request
Mar 20, 2026
…industries#51985) ## Context Fixes the visual selection update in `TextDiffView::open` to properly convert between buffer-local and multibuffer coordinates using `buffer_point_to_anchor`. Previously, raw multibuffer Points were used directly for line expansion, which produced incorrect regions when expanded deleted diff hunks shifted multibuffer row numbers. This provides a single unified code path for both singleton and non-singleton multibuffers, as suggested in [zed-industries#51457 review feedback](zed-industries#51457 (comment)). Follow-up to zed-industries#51457. ## How to Review Small PR - all changes are in `crates/git_ui/src/text_diff_view.rs`. Focus on: - `open()`: The visual selection update block now uses `buffer_point_to_anchor` + `to_point` instead of raw multibuffer coordinate math - No more assumption that multibuffer Points == buffer-local Points - Existing tests validate both singleton and non-singleton multibuffer paths ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] The content is consistent with the UI/UX checklist - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed incorrect diff region when using "Diff Clipboard with Selection" with expanded diff hunks in the editor.
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 23, 2026
…industries#51985) ## Context Fixes the visual selection update in `TextDiffView::open` to properly convert between buffer-local and multibuffer coordinates using `buffer_point_to_anchor`. Previously, raw multibuffer Points were used directly for line expansion, which produced incorrect regions when expanded deleted diff hunks shifted multibuffer row numbers. This provides a single unified code path for both singleton and non-singleton multibuffers, as suggested in [zed-industries#51457 review feedback](zed-industries#51457 (comment)). Follow-up to zed-industries#51457. ## How to Review Small PR - all changes are in `crates/git_ui/src/text_diff_view.rs`. Focus on: - `open()`: The visual selection update block now uses `buffer_point_to_anchor` + `to_point` instead of raw multibuffer coordinate math - No more assumption that multibuffer Points == buffer-local Points - Existing tests validate both singleton and non-singleton multibuffer paths ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] The content is consistent with the UI/UX checklist - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed incorrect diff region when using "Diff Clipboard with Selection" with expanded diff hunks in the editor.
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.
Context
Fixes the visual selection update in
TextDiffView::opento properly convert between buffer-local and multibuffer coordinates usingbuffer_point_to_anchor. Previously, raw multibuffer Points were used directly for line expansion, which produced incorrect regions when expanded deleted diff hunks shifted multibuffer row numbers.This provides a single unified code path for both singleton and non-singleton multibuffers, as suggested in #51457 review feedback.
Follow-up to #51457.
How to Review
Small PR - all changes are in
crates/git_ui/src/text_diff_view.rs. Focus on:open(): The visual selection update block now usesbuffer_point_to_anchor+to_pointinstead of raw multibuffer coordinate mathSelf-Review Checklist
Release Notes: