Skip to content

Fix go-to-definition for multi-source declaration maps - #4829

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
mainfrom
copilot/lsp-fix-go-to-definition
Draft

Fix go-to-definition for multi-source declaration maps#4829
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
mainfrom
copilot/lsp-fix-go-to-definition

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Go-to-definition combined the mapped declaration context URI (sources[0]) with the correctly mapped identifier range from another source. This returned the right position in the wrong file.

Changes

  • When context and identifier mappings resolve to different files, use the identifier mapping for the complete definition link.
  • Add regression coverage for a declaration map whose identifier maps to sources[6].

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Go to Definition source mapping issue in LSP Fix go-to-definition for multi-source declaration maps Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot this fix doesn't make any sense to me. If the only correct .Uri is targetSelectionLoc then why are we computing targetLoc in the first place?

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Copilot this fix doesn't make any sense to me. If the only correct .Uri is targetSelectionLoc then why are we computing targetLoc in the first place?

targetSelectionLoc is now always authoritative for TargetUri. The context mapping is computed only to provide the broader TargetRange, and only when it maps to the same URI; otherwise the selection range is used for both ranges. Addressed in d9ec7ca.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lsp] Go to Definition returns sources[0] of the declaration map instead of the mapped source file

2 participants