# edit_prediction: Fix v4 cursor placement \(\#61901\) · gitcafe/zed

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

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

Visibility: public

Requested revision: f851d82e880c152d0f41e4a60d363aa82b4b8114

Requested commit: f851d82e880c152d0f41e4a60d363aa82b4b8114

Commit: f851d82e880c152d0f41e4a60d363aa82b4b8114

Tree: defdc212bcd4aca0e3e23b6075060a7c3d7da17b

Author: Ben Kunkle

Committer: GitHub

## Message

```
edit_prediction: Fix v4 cursor placement (#61901)

# Objective

Prevent accepted v4 edit predictions from moving the cursor past the
model's predicted position.

## Solution

Keep the cursor's base anchor fixed while applying inserted text, then
apply the model-provided offset. Add regression coverage based on the
reported cursor jump.

## 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
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
```

## Parents

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

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