Skip to content

Commit 0a7c24b

Browse files
fix(#2568): hijack_cursor positions at top grouped node (#2569)
Co-authored-by: Azad <49314270+Akmadan23@users.noreply.github.com>
1 parent 27e66c2 commit 0a7c24b

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
@@ -124,6 +124,7 @@ function M.place_cursor_on_node()
124124
if not node or node.name == ".." then
125125
return
126126
end
127+
node = utils.get_parent_of_group(node)
127128

128129
local line = vim.api.nvim_get_current_line()
129130
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)