vim: Update anchor used for LSP operations#60365
Open
dinocosta wants to merge 1 commit into
Open
Conversation
In helix and vim visual modes, the head of a forward selection is its exclusive end, so it sits one position past the rendered block cursor. Operations targeting the symbol under the cursor queried the head directly and could miss the symbol entirely, e.g. landing in the whitespace after a `w` motion. Generalize the existing rename adjustment (`rename_target_anchor`, now `symbol_target_anchor`) and apply it to go to definition, declaration, type definition, and implementation, find all references, go to next/previous reference, hover, and LSP document highlights.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Followup to #55542 , ensuring that we apply the same anchor calculation logic when performing hover, go to definition, go to declaration, go to type definition, go to implementation, find all references, go to reference, hover and document highlights.
Solution
In helix and vim visual modes, the head of a forward selection is its exclusive end, so it sits one position past the rendered block cursor. Operations targeting the symbol under the cursor queried the head directly and could miss the symbol entirely, for example, landing in the whitespace after a
wmotion.The changes in #55542 fixed this for the case when renaming a symbol, but there's other places where
Selection::headwas still being used.hover, go to definition, go to declaration, go to type definition, go to implementation, find all references, go to reference, hover and document highlights.
Testing
Tested both manually as well as introduced a new test for the go to definition case –
vim::helix::test::test_helix_go_to_definition_uses_visible_cursor_position.Self-Review Checklist:
Showcase
Go To Definition • Before
CleanShot.2026-07-03.at.17.53.25.mp4
Go To Definition • After
CleanShot.2026-07-03.at.17.54.48.mp4
Release Notes: