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.
This commit is contained in:
@@ -381,6 +381,8 @@ impl EditorElement {
|
||||
register_action(editor, window, Editor::go_to_prev_diagnostic);
|
||||
register_action(editor, window, Editor::go_to_next_hunk);
|
||||
register_action(editor, window, Editor::go_to_prev_hunk);
|
||||
register_action(editor, window, Editor::go_to_next_document_highlight);
|
||||
register_action(editor, window, Editor::go_to_prev_document_highlight);
|
||||
register_action(editor, window, |editor, action, window, cx| {
|
||||
editor
|
||||
.go_to_definition(action, window, cx)
|
||||
|
||||
Reference in New Issue
Block a user