File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,27 @@ function M.out(node)
3535 if not candidate then
3636 candidate = strategies .get_first_ancestor_jump_target (node )
3737 end
38+ -- When in a comment, try to jump to the declaration it's attached to
39+ if node :type ():match (" comment" ) then
40+ if candidate and candidate :type ():match (" body" ) then
41+ -- Comment inside a body - go to the parent declaration
42+ local declaration = candidate :parent ()
43+ if declaration and nodes .is_jump_target (declaration ) then
44+ candidate = declaration
45+ end
46+ elseif not candidate then
47+ -- No candidate found, walk up from comment to find a sibling declaration
48+ local comment_parent = node :parent ()
49+ while comment_parent do
50+ if comment_parent :type ():match (" body" ) then
51+ -- We're inside a body, go to its parent
52+ candidate = comment_parent :parent ()
53+ break
54+ end
55+ comment_parent = comment_parent :parent ()
56+ end
57+ end
58+ end
3859 candidate = coincident (candidate )
3960 if not candidate then return end
4061 local row = nodes .get_srow (candidate )
You can’t perform that action at this time.
0 commit comments