Skip to content

Commit

Permalink
refactor: save TSNode directly
Browse files Browse the repository at this point in the history
  • Loading branch information
ofseed committed Sep 7, 2024
1 parent 5c6db01 commit d35952c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/nvim-treesitter-textobjects/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ local function get_capture_ranges_recursively(bufnr, query_string, query_group)
for _, match in pairs(matches) do
local found = get_at_path(match, query_string)
if found then
---@cast found Range6
table.insert(ranges, found)
---@cast found TSNode
table.insert(ranges, { found:range(true) })
end
end
end)
Expand Down Expand Up @@ -194,7 +194,9 @@ function M.find_best_range(bufnr, capture_string, query_group, filter_predicate,

local matches = get_query_matches(bufnr, query_group, root, lang)
for _, maybe_match in pairs(matches) do
local range = get_at_path(maybe_match, capture_string)
local node = get_at_path(maybe_match, capture_string)
---@cast node TSNode
local range = { node:range(true) }
---@cast range Range6

if range and filter_predicate(range) then
Expand Down

0 comments on commit d35952c

Please sign in to comment.