fix(#2568): hijack_cursor positions at top grouped node (#2569)

Co-authored-by: Azad <49314270+Akmadan23@users.noreply.github.com>
This commit is contained in:
Alexander Courtis 2023-12-10 10:13:22 +11:00 committed by GitHub
parent 27e66c2ea8
commit 0a7c24b675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -124,6 +124,7 @@ function M.place_cursor_on_node()
if not node or node.name == ".." then
return
end
node = utils.get_parent_of_group(node)
local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0)

View File

@ -150,11 +150,10 @@ function M.get_node_from_path(path)
end
---Get the highest parent of grouped nodes
---@param node_ Node
---@return table
function M.get_parent_of_group(node_)
local node = node_
while node.parent and node.parent.group_next do
---@param node Node
---@return Node node or parent
function M.get_parent_of_group(node)
while node and node.parent and node.parent.group_next do
node = node.parent
end
return node