Skip to content

Commit 5d37874

Browse files
committed
Prev still failed CI
1 parent 96ba1a9 commit 5d37874

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lua/treewalker/targets.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)