# editor: Fix missing background highlights in multibuffer find-all-references \(\#55863\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 29dc988f15bdd7c93d66e6a83b93032d202fa2f2

Requested commit: 29dc988f15bdd7c93d66e6a83b93032d202fa2f2

Commit: 29dc988f15bdd7c93d66e6a83b93032d202fa2f2

Tree: 839bb1c1852f26f0a0864c6563e09b6abbbe875b

Author: Xin Zhao

Committer: GitHub

## Message

```
editor: Fix missing background highlights in multibuffer find-all-references (#55863)

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)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

The root cause is in this part of code:

https://github.com/zed-industries/zed/blob/f5945344cc21ebff07eb7ea04dab0555fbe49007/crates/editor/src/editor.rs#L19446-L19464
The ranges across multibuffer are stored in the order of the HashMap
iterator, which is not sorted at all. They are then consumed by
`background_highlights_in_range()`, which uses a binary search that
requires the ranges to be sorted:

https://github.com/zed-industries/zed/blob/f5945344cc21ebff07eb7ea04dab0555fbe49007/crates/editor/src/editor.rs#L24127-L24135
The fix sorts the ranges by multibuffer anchor position before storing
them.

Release Notes:

- Fixed missing background highlights in "Find All References" when
results span multiple files.
```

## Parents

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

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