# editor: Implement Go to next/prev Document Highlight \(\#35994\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 14ffd7b53fb69cbee6e979efe5fc0ea5ece101f7

Requested commit: 14ffd7b53fb69cbee6e979efe5fc0ea5ece101f7

Commit: 14ffd7b53fb69cbee6e979efe5fc0ea5ece101f7

Tree: 9198eb581b6ffa52bf59bbe90352fa99b5c1be60

Author: Marco Munizaga

Committer: GitHub

## Message

```
editor: Implement Go to next/prev Document Highlight (#35994)

Closes #21193
Closes #14703 

Having the ability to navigate directly to the next
symbolHighlight/reference lets you follow the data flow of a variable.
If you highlight the function itself (depending on the LSP), you can
also navigate to all returns.

Note that this is a different feature from navigating to the next match,
as that is not language-context aware. For example, if you have a var
named foo it would also navigate to an unrelated variable fooBar.

Here's how this patch works:

- The editor struct has a background_highlights.
- Collect all highlights with the keys [DocumentHighlightRead,
DocumentHighlightWrite]
- Depending on the direction, move the cursor to the next or previous
highlight relative to the current position.

Release Notes:

- Added `editor::GoToNextDocumentHighlight` and
`editor::GoToPreviousDocumentHighlight` to navigate to the next LSP
document highlight. Useful for navigating to the next usage of a certain
symbol.
```

## Parents

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

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