Skip to content

Commit 0921c96

Browse files
committed
fix(#2568): hijack_cursor positions at top grouped node
1 parent 13f967f commit 0921c96

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function M.place_cursor_on_node()
148148
if not node or node.name == ".." then
149149
return
150150
end
151+
node = utils.get_parent_of_group(node)
151152

152153
local line = vim.api.nvim_get_current_line()
153154
local cursor = vim.api.nvim_win_get_cursor(0)

lua/nvim-tree/utils.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ function M.get_node_from_path(path)
149149
:iterate()
150150
end
151151

152-
--- Get the highest parent of grouped nodes
153-
---@param node_ Node
154-
---@return table
155-
function M.get_parent_of_group(node_)
156-
local node = node_
157-
while node.parent and node.parent.group_next do
152+
---Get the highest parent of grouped nodes
153+
---@param node Node
154+
---@return Node node or parent
155+
function M.get_parent_of_group(node)
156+
while node and node.parent and node.parent.group_next do
158157
node = node.parent
159158
end
160159
return node

0 commit comments

Comments
 (0)