# copilot: Fix panic in Copilot edit prediction due to anchor/snapshot mismatch \(\#46022\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5505e63a0df191aeed2988e5cd8073f2761f4303

Requested commit: 5505e63a0df191aeed2988e5cd8073f2761f4303

Commit: 5505e63a0df191aeed2988e5cd8073f2761f4303

Tree: e6900e87ab2779c696d1851c0c2b176f78d2fd02

Author: Vadim Suharnikov

Committer: GitHub

## Message

```
copilot: Fix panic in Copilot edit prediction due to anchor/snapshot mismatch (#46022)

When `trim_completion()` creates new anchors from the current buffer
state, `completion.snapshot` was not being updated, leaving it with the
older snapshot from when the prediction was initially fetched. This
caused a panic in `interpolate_edits()` when trying to resolve anchors
with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new
anchors are created in `trim_completion()`, keeping the snapshot and
anchors consistent.

Closes #45956

Release Notes:

- Fixed a panic in Copilot edit predictions caused by anchor/snapshot
version mismatch
```

## Parents

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

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