Skip to content

Fix hover/go-to-definition on vars, types, and methods (compound highlight spans) - #41

Open
bad33ndj3 wants to merge 1 commit into
mainfrom
fix/compound-highlight-span-identifier
Open

Fix hover/go-to-definition on vars, types, and methods (compound highlight spans)#41
bad33ndj3 wants to merge 1 commit into
mainfrom
fix/compound-highlight-span-identifier

Conversation

@bad33ndj3

Copy link
Copy Markdown
Owner

Summary

  • caretElementMatchesIdentifier required a caret hit's DOM element to have trimmed text exactly equal to the identifier. GitLab's syntax highlighter frequently groups several tokens into one span — e.g. hljs-params wraps an entire (t *runAtTimerTask) method receiver, and a trailing span often holds a method name plus its parens.
  • Live-verified on gitlab.com (gitlab-runner/commands/multi.go): package names mostly sit alone in their own span and matched fine; vars, types, and method names usually don't, so hover/go-to-definition silently failed for most of them ("GoLens could not identify a Go symbol on this diff line").
  • Fix: also accept the identifier as a whole word within the element's text (still guarded by identifier boundaries, so a caret snapping onto an adjacent identifier is still rejected).

Test plan

  • npm run check:syntax
  • npm test (540/540 on main)
  • New unit test covering the compound-span case (hljs-params receiver) plus a negative case (Timer is not a whole-word match inside runAtTimerTask)

🤖 Generated with Claude Code

https://claude.ai/code/session_01NbVVA6kUeVF2Kx8FJJVMsj

GitLab's highlighter sometimes groups several tokens into one span
(e.g. hljs-params wrapping an entire "(t *runAtTimerTask)" receiver,
or a trailing span holding a method name plus its parens).
caretElementMatchesIdentifier required the span's whole trimmed text
to equal the identifier, so hover/go-to-definition silently failed on
most vars, types, and methods while still working on package names
(which usually sit alone in their own span).

Now also accepts the identifier as a whole word within the span's
text, guarded by identifier boundaries so it still rejects a caret
snapping onto an adjacent identifier.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NbVVA6kUeVF2Kx8FJJVMsj
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.

1 participant