File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments