# editor: Fix panic when confirming completion across buffers \(\#59471\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2ec0e6c2d7024f684e8bc23ce5882419b81f7f11

Requested commit: 2ec0e6c2d7024f684e8bc23ce5882419b81f7f11

Commit: 2ec0e6c2d7024f684e8bc23ce5882419b81f7f11

Tree: b35b3af1c83c13f184b747864270064b6e85ea1d

Author: Neel

Committer: GitHub

## Message

```
editor: Fix panic when confirming completion across buffers (#59471)

In multi-buffer context, `do_completion` resolved the completion's
replace range anchors against whichever buffer currently held the newest
selection. If that selection had moved into a different file's excerpt
(while the menu remained open), the anchors belonged to a different
buffer and caused a panic.

This PR adds a guard to confirm the completion buffer and selection
buffer is the same.

Closes FR-76.

---

Release Notes:

- Fixed a panic that could occur when confirming a completion in a
multibuffer if the cursor had moved into a different file
```

## Parents

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

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