# helix: Fix paste in deleted diff hunks \(\#64245\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a95da07db20cf36bd750ecc4bdfecdf2b29e3f0f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a95da07db20cf36bd750ecc4bdfecdf2b29e3f0f

Requested commit: a95da07db20cf36bd750ecc4bdfecdf2b29e3f0f

Commit: a95da07db20cf36bd750ecc4bdfecdf2b29e3f0f

Tree: 510af9241a4583ca53ec441e7b1c7c72fc40d380

Author: Agus Zubiaga

Committer: GitHub

## Message

```
helix: Fix paste in deleted diff hunks (#64245)

Closes ZED-73F

# Objective

Pasting in Helix mode while the cursor was inside an expanded deleted
diff hunk could create a selection past the buffer and crash.

## Solution

Track the inserted range with before/after anchors instead of deriving
it from the clipboard text length. If the edit is rejected for
non-editable diff text, both anchors resolve to an empty valid range.

## Testing

Added a regression test for pasting inside an expanded deleted hunk and
ran the Helix paste tests.

## 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 adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed a crash when pasting in an expanded deleted diff hunk in Helix
mode
```

## Parents

- [aef893e27613ccddcb04a74ea90fc148558e63da](https://git.cafe/gitcafe/zed/commit/aef893e27613ccddcb04a74ea90fc148558e63da?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a95da07db20cf36bd750ecc4bdfecdf2b29e3f0f?format=markdown)
