Skip to content

Commit

Permalink
refactor: save TSNode directly
Browse files Browse the repository at this point in the history
  • Loading branch information
ofseed authored and clason committed Aug 30, 2024
1 parent 21a1fd8 commit 0ba9dd9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/nvim-treesitter-textobjects/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ local get_query_matches = memoize(function(bufnr, query_group, root, root_lang)
if query_name ~= nil then
local path = vim.split(query_name, "%.")
for _, node in ipairs(nodes) do
insert_to_path(prepared_match, path, { node:range(true) })
insert_to_path(prepared_match, path, node)
end
end
end
Expand Down Expand Up @@ -143,8 +143,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 @@ -178,7 +178,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 0ba9dd9

Please sign in to comment.