Skip to content

vim: Update anchor used for LSP operations#60365

Open
dinocosta wants to merge 1 commit into
mainfrom
helix/symbol-target-anchor
Open

vim: Update anchor used for LSP operations#60365
dinocosta wants to merge 1 commit into
mainfrom
helix/symbol-target-anchor

Conversation

@dinocosta

Copy link
Copy Markdown
Member

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.

  • Describe the objective or issue this PR addresses.
  • If you're fixing a specific issue, use "Fixes #X" for each issue as described in the GitHub docs.

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 w motion.

The changes in #55542 fixed this for the case when renaming a symbol, but there's other places where Selection::head was 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:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

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:

  • Improved LSP symbol operations (go to definition, find all references, hover, etc.) missing the symbol under the visible selection in Helix mode.

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.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 3, 2026
@dinocosta dinocosta self-assigned this Jul 3, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant