Skip to content

helix: Fix paste crash (#58373) (cherry-pick to preview)#58415

Merged
zed-zippy[bot] merged 1 commit into
v1.5.xfrom
cherry-pick-v1.5.x-1125a45d
Jun 3, 2026
Merged

helix: Fix paste crash (#58373) (cherry-pick to preview)#58415
zed-zippy[bot] merged 1 commit into
v1.5.xfrom
cherry-pick-v1.5.x-1125a45d

Conversation

@zed-zippy

@zed-zippy zed-zippy Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #58373 to preview


Closes #58343

This crash happened because Helix paste restored selection using the raw
clipboard text length, but buffer edits normalize CRLF line endings to
LF before inserting. When pasting CRLF text at or near EOF, the restored
selection could extend past the normalized snapshot length and panic in
MutableSelectionsCollection::select_ranges. The fix normalizes the
text before measuring it for selection restoration and adds regression
coverage for CRLF paste in Helix mode.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • 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 a crash that could occur when pasting at the end of a file in
    Helix mode

Closes [#58343](<#58343>)

This crash happened because Helix paste restored selection using the raw
clipboard text length, but buffer edits normalize CRLF line endings to
LF before inserting. When pasting CRLF text at or near EOF, the restored
selection could extend past the normalized snapshot length and panic in
`MutableSelectionsCollection::select_ranges`. The fix normalizes the
text before measuring it for selection restoration and adds regression
coverage for CRLF paste in Helix mode.

Self-Review Checklist:

- [X] I've reviewed my own diff for quality, security, and reliability
- [X] Unsafe blocks (if any) have justifying comments
- [X] The content is consistent with the [UI/UX
checklist](<https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist>)
- [X] Tests cover the new/changed behavior
- [X] Performance impact has been considered and is acceptable

Release Notes:

- Fixed a crash that could occur when pasting at the end of a file in
Helix mode
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 3, 2026
@zed-community-bot zed-community-bot Bot added the bot Pull requests authored by a bot label Jun 3, 2026
@zed-zippy zed-zippy Bot merged commit 331fa59 into v1.5.x Jun 3, 2026
41 checks passed
@zed-zippy zed-zippy Bot deleted the cherry-pick-v1.5.x-1125a45d branch June 3, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot Pull requests authored by a bot cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant