Skip to content

Commit 7318d7a

Browse files
committed
fix(#2568): hijack_cursor positions at top grouped node
1 parent 05f55c1 commit 7318d7a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function M.place_cursor_on_node()
143143
if not node or node.name == ".." then
144144
return
145145
end
146+
node = utils.get_parent_of_group(node)
146147

147148
local line = vim.api.nvim_get_current_line()
148149
local cursor = vim.api.nvim_win_get_cursor(0)

lua/nvim-tree/utils.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ function M.get_node_from_path(path)
127127
:iterate()
128128
end
129129

130-
-- get the highest parent of grouped nodes
131-
function M.get_parent_of_group(node_)
132-
local node = node_
133-
while node.parent and node.parent.group_next do
130+
---Get the highest parent of grouped nodes
131+
---@param node table
132+
---@return table node or parent
133+
function M.get_parent_of_group(node)
134+
while node and node.parent and node.parent.group_next do
134135
node = node.parent
135136
end
136137
return node

0 commit comments

Comments
 (0)