Resolve goto-def/refs/hover at the end of a symbol (#1038 / #1027)#1270
Merged
Conversation
Bump elixir_sense to 9f6b3fe, which makes `SurroundContext.Toxic.surround_context` resolve the trailing edge of a symbol. All four navigation locators (definition, references, implementation, hover) consume it, so the cursor placed at the visual end of a name now resolves instead of returning nothing (#1038), and the end of an alias before a `.` resolves to the module rather than the remote call (#1027). Add end-to-end coverage in the definition locator test for both cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRd15BX6wBpZ8ThaNSo232
…hover) elixir_sense ee88a26f restricts the end-of-alias-before-dot override to `:alias` only, so hovering the `.` in an erlang remote call like `:timer.sleep(...)` keeps resolving the function instead of the module. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRd15BX6wBpZ8ThaNSo232
Collaborator
Author
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR updates the pinned elixir_sense dependency to pick up fixes for trailing-edge cursor classification (cursor one column past a symbol / at the end of an alias before .), and adds regression tests in ElixirLS to ensure goto-definition works correctly in those positions.
Changes:
- Bump
elixir_sensegit ref SHA to a newer commit that includes the trailing-edge surround-context fix. - Update the repository’s recorded dependency SHA (
dep_versions.exs) to match the new pin. - Add definition-locator regression tests for “cursor at end of symbol” (#1038) and “alias end before
.resolves module” (#1027).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mix.lock | Pins elixir_sense to the updated git SHA. |
| dep_versions.exs | Updates the tracked elixir_sense SHA to match the lockfile. |
| apps/language_server/test/providers/definition/locator_test.exs | Adds regression coverage for end-of-symbol and alias-before-dot behavior in goto-definition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+23
| # elixir-lsp/elixir-ls#1038: goto-definition must work when the cursor is at the very end of a | ||
| # symbol (one column past its last character), not only when it is on a character of the symbol. | ||
| test "find definition with the cursor at the end of the symbol (#1038)" do |
…hover Per review of #1270, the trailing-edge regression coverage previously only exercised the definition locator. Add equivalent "cursor at end of symbol / end of alias before `.`" cases for the References and Implementation locators and the Hover provider, which share the same SurroundContext.Toxic resolution, so those paths can't regress independently. Also bump elixir_sense to 9460c606 (review fixes: lazy classification, operator contexts preserved, qualified-alias override). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRd15BX6wBpZ8ThaNSo232
lukaszsamson
added a commit
that referenced
this pull request
Jul 4, 2026
… branch Pin conflict resolved keeping ours: master pins elixir_sense 9460c606, which is an ancestor of our 9788101d (the #334 merge commit on elixir_sense master). Gates: compile 0 warnings, format clean, language_server suite 1624 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvwMWQayfdxowBDrnt5iYM
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.
Fixes #1038. Addresses the #1027 cases. Supersedes #1087 (the retry-with-char-to-the-left workaround).
Problem
SurroundContext.Toxic.surround_context/2mirroredCode.Fragment.surround_context/2, which returns:nonewhen the cursor is one column past the last character of a symbol, and returns the enclosing remote call when the cursor is at the end of an alias before a.. So goto-definition / references / hover fail when the caret is at the visual end of a name (#1038), and an alias at its end resolves to the function instead of the module (#1027; the upstream lexical fix elixir-lang/elixir#13150 was reverted as it only handled a few cases).Fix
The fix is in
elixir_sense(PR elixir-lsp/elixir_sense#340); this PR bumps the dependency and adds end-to-end coverage. Because toxic2 gives every node an exact end-exclusive range, the classifier now resolves the trailing edge precisely:FooinFoo.bar()is the moduleFoo(Inconsistency in go-to definition/references for modules based on syntax #1027);key:/operator/sigil trailing edge stays:none) → end of a bare symbol or of a whole remote call resolves (Go to Definition/Find References functionality doesn't work when cursor is at end of symbol #1038).All four locators (definition/references/implementation/hover) consume
surround_context, so they are fixed together.Safety
Fuzzed across lib + fixtures at every column: 0 results where the cursor falls outside the returned
[begin, end], and by construction the result is:noneonly where the pre-existing classification was — nothing regresses. The 285 existing navigation-locator tests still pass.🤖 Generated with Claude Code