Skip to content

git_ui: Fix multibuffer coordinate conversion in clipboard diff#51985

Merged
Veykril merged 2 commits intozed-industries:mainfrom
OmChillure:git_ui/fix-diff-clipboard-multibuffer
Mar 20, 2026
Merged

git_ui: Fix multibuffer coordinate conversion in clipboard diff#51985
Veykril merged 2 commits intozed-industries:mainfrom
OmChillure:git_ui/fix-diff-clipboard-multibuffer

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

@OmChillure OmChillure commented Mar 20, 2026

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 #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 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

  • I've reviewed my own diff for quality, security, and reliability
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • 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.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 20, 2026
@zed-community-bot zed-community-bot bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 20, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, Veykril and kubkon and removed request for a team March 20, 2026 04:39
@OmChillure OmChillure changed the title it_ui: Fix multibuffer coordinate conversion in clipboard diff git_ui: Fix multibuffer coordinate conversion in clipboard diff Mar 20, 2026
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Thanks!

@Veykril Veykril enabled auto-merge (squash) March 20, 2026 06:45
auto-merge was automatically disabled March 20, 2026 07:00

Head branch was pushed to by a user without write access

@OmChillure
Copy link
Copy Markdown
Contributor Author

OmChillure commented Mar 20, 2026

@Veykril can you approve again, please sorry forgot the fmt again !

Thanks

@OmChillure
Copy link
Copy Markdown
Contributor Author

Thanks!

Happy to contribute

@Veykril Veykril enabled auto-merge (squash) March 20, 2026 07:22
@Veykril Veykril merged commit 2839676 into zed-industries:main Mar 20, 2026
30 checks passed
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.
@esthertrapadoux esthertrapadoux moved this to Shipped by the Guild in Zed Guild - The Board Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions Size M

Projects

Status: Shipped by the Guild

Development

Successfully merging this pull request may close these issues.

3 participants