Skip to content

Fix crash: vim paste panics on editor-copied entire-line selections#49134

Merged
eholk merged 1 commit intomainfrom
crash-fix/zed-47d
Feb 18, 2026
Merged

Fix crash: vim paste panics on editor-copied entire-line selections#49134
eholk merged 1 commit intomainfrom
crash-fix/zed-47d

Conversation

@eholk
Copy link
Contributor

@eholk eholk commented Feb 13, 2026

When clipboard data was produced by the editor's copy/cut with multiple entire-line selections, vim's paste would panic with byte index N is out of bounds.

The editor's do_copy and cut_common skip the \n separator between clipboard selections when the previous selection was an entire-line selection (because the text already ends with \n). However, vim's paste code unconditionally did start_offset = end_offset + 1, always assuming a \n separator exists between every pair of selections. This caused the accumulated offset to exceed the text length, resulting in a string slicing panic.

The fix checks clipboard_selection.is_entire_line to decide whether to skip the separator, matching the behavior of the editor's own do_paste method. The same fix is applied to both the vim and helix paste implementations.

Release Notes:

  • Fixed a crash when using vim paste on clipboard data copied with the editor's copy command containing multiple entire-line selections.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 13, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 13, 2026
@eholk eholk marked this pull request as ready for review February 13, 2026 22:04
The editor's copy/cut skips the newline separator between entire-line
clipboard selections (since the text already ends with newline), but vim's
paste unconditionally assumed a newline separator by always adding +1 to
start_offset. This caused out-of-bounds string indexing when pasting
clipboard data produced by the editor's copy with multiple entire-line
selections.
@eholk eholk force-pushed the crash-fix/zed-47d branch from d856571 to 8ad1bc0 Compare February 18, 2026 23:36
@eholk eholk requested a review from a team as a code owner February 18, 2026 23:36
@eholk eholk merged commit 9b07658 into main Feb 18, 2026
27 checks passed
@eholk eholk deleted the crash-fix/zed-47d branch February 18, 2026 23:55
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant