# Fix panic in \`multi_buffer::Anchor::is_valid\` \(\#55644\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 11371e6e1b9ae0244d17fcaa63dbc2603ece0783

Requested commit: 11371e6e1b9ae0244d17fcaa63dbc2603ece0783

Commit: 11371e6e1b9ae0244d17fcaa63dbc2603ece0783

Tree: 4affa0173f10e3060b1bd660fd44b7efd5959383

Author: Cole Miller

Committer: GitHub

## Message

```
Fix panic in `multi_buffer::Anchor::is_valid` (#55644)

We check `is_valid` by seeking to the first excerpt that is `>=` the
anchor, and comparing the anchor to the excerpt's start and end. But we
were missing a check for the case where seeking puts us on an excerpt
for a different buffer, for example when the anchor to be checked is
past the end of the context range for its buffer's last excerpt.

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 panic in multibuffers.
```

## Parents

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

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