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 if not node or node.name == ".." then
return return
end end
node = utils.get_parent_of_group(node)
local line = vim.api.nvim_get_current_line() local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0) local cursor = vim.api.nvim_win_get_cursor(0)

View File

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