Skip to content

Use buffer line numbers when copying file locations#60781

Open
apoorva-01 wants to merge 1 commit into
zed-industries:mainfrom
apoorva-01:fix-copy-file-location-multibuffer
Open

Use buffer line numbers when copying file locations#60781
apoorva-01 wants to merge 1 commit into
zed-industries:mainfrom
apoorva-01:fix-copy-file-location-multibuffer

Conversation

@apoorva-01

Copy link
Copy Markdown
Contributor

Objective

Fixes #54250

editor: copy file location copies the row you're on in the multi-buffer, not the row in the actual file. In a git diff view with collapsed lines it copies the wrong line number.

Solution

It read the rows straight off the selection, which is in multi-buffer coordinates. ClipboardSelection::for_buffer already handles this with range_to_buffer_range, so I used the same thing. Path and line now come from the same buffer.

range_to_buffer_range returns nothing when the selection ends in a different buffer than it starts in, which you can do in a git diff view. Rather than copy nothing, it falls back to the cursor's buffer.

Testing

Three tests: a multi-buffer excerpt, a selection dragged across two files, and a plain single-file editor. The multi-buffer ones fail on main; the singleton one passes either way, so normal editors are unaffected.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed editor: copy file location copying the wrong line number in multibuffers (#54250).

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 10, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy file location in multi-buffer copies wrong line

1 participant