Skip to content

Conversation

@dinocosta
Copy link
Member

@dinocosta dinocosta commented Jan 12, 2026

When using the editor::actions::CopyAndTrim action with a multi-line selection in vim's Visual Line mode, pasting would crash Zed.

The bug occurred because trimming splits a selection into per-line ranges, creating multiple editor::ClipboardSelection entries. However, when is_entire_line was true (Visual Line mode), no newline separators were added between these entries in the clipboard text. The paste code then assumed separators existed and read past the end of the text.

The fix ensures newline separators are always added between trimmed line ranges, regardless of whether the original selection was in line mode.

Closes #46616

Release Notes:

  • Fixed a crash when pasting after using editor: copy and trim in vim's Visual Line mode
When using the `editor::actions::CopyAndTrim` action with a multi-line
selection in vim's Visual Line mode, pasting would crash Zed.

The bug occurred because trimming splits a selection into per-line
ranges, creating multiple `editor::ClipboardSelection` entries. However,
when `is_entire_line` was true (Visual Line mode), no newline separators
were added between these entries in the clipboard text. The paste code
then assumed separators existed and read past the end of the text.

The fix ensures newline separators are always added between trimmed line
ranges, regardless of whether the original selection was in line mode.
@dinocosta dinocosta self-assigned this Jan 12, 2026
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 12, 2026
@dinocosta dinocosta force-pushed the 46616-fix-copy-and-trim branch from 67453e7 to dcc6a59 Compare January 12, 2026 18:18
@dinocosta dinocosta enabled auto-merge (squash) January 12, 2026 18:20
@dinocosta dinocosta merged commit 0ecefe0 into main Jan 13, 2026
35 of 40 checks passed
@dinocosta dinocosta deleted the 46616-fix-copy-and-trim branch January 13, 2026 11:57
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

2 participants