Skip to content

Commit 869467a

Browse files
committed
Simplified fix - minimal changes (Sun Nov 2 12:59:17 PST 2025)
1 parent 3f41ebe commit 869467a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lua/treewalker/targets.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ function M.out(node)
3232
return markdown_targets.out()
3333
end
3434

35+
-- Special handling for comments - find containing declaration
36+
if node:type():match("comment") then
37+
local cursor_pos = vim.api.nvim_win_get_cursor(0)
38+
local cursor_row, cursor_col = cursor_pos[1] - 1, cursor_pos[2] -- Convert to 0-indexed
39+
local actual_node = vim.treesitter.get_node({ pos = { cursor_row, cursor_col } })
40+
if actual_node and actual_node:type():match("comment") then
41+
local parent = actual_node:parent()
42+
while parent do
43+
if parent:type() == "class_declaration" and nodes.is_jump_target(parent) then
44+
return parent, nodes.get_srow(parent)
45+
end
46+
parent = parent:parent()
47+
end
48+
end
49+
end
50+
3551
local candidate = strategies.get_first_ancestor_with_diff_scol(node)
3652
-- If no ancestor with different column found, try to find the first valid ancestor
3753
if not candidate then

0 commit comments

Comments
 (0)