Skip to content

Commit

Permalink
fix: nil index when swapping at first/last child (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 authored Mar 5, 2024
1 parent 3532f60 commit cf3d612
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/nvim-treesitter/textobjects/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ function M.next_textobject(node, query_string, query_group, same_parent, overlap

local next_node = queries.find_best_match(bufnr, query_string, query_group, filter_function, scoring_function)

return next_node and next_node.node, next_node.metadata
if next_node then
return next_node.node, next_node.metadata
end
end

function M.previous_textobject(node, query_string, query_group, same_parent, overlapping_range_ok, bufnr)
Expand Down Expand Up @@ -367,7 +369,9 @@ function M.previous_textobject(node, query_string, query_group, same_parent, ove

local previous_node = queries.find_best_match(bufnr, query_string, query_group, filter_function, scoring_function)

return previous_node and previous_node.node, previous_node.metadata
if previous_node then
return previous_node.node, previous_node.metadata
end
end

return M

0 comments on commit cf3d612

Please sign in to comment.