Skip to content

Commit 0ba9dd9

Browse files
ofseedclason
authored andcommitted
refactor: save TSNode directly
1 parent 21a1fd8 commit 0ba9dd9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lua/nvim-treesitter-textobjects/shared.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ local get_query_matches = memoize(function(bufnr, query_group, root, root_lang)
8484
if query_name ~= nil then
8585
local path = vim.split(query_name, "%.")
8686
for _, node in ipairs(nodes) do
87-
insert_to_path(prepared_match, path, { node:range(true) })
87+
insert_to_path(prepared_match, path, node)
8888
end
8989
end
9090
end
@@ -143,8 +143,8 @@ local function get_capture_ranges_recursively(bufnr, query_string, query_group)
143143
for _, match in pairs(matches) do
144144
local found = get_at_path(match, query_string)
145145
if found then
146-
---@cast found Range6
147-
table.insert(ranges, found)
146+
---@cast found TSNode
147+
table.insert(ranges, { found:range(true) })
148148
end
149149
end
150150
end)
@@ -178,7 +178,9 @@ function M.find_best_range(bufnr, capture_string, query_group, filter_predicate,
178178

179179
local matches = get_query_matches(bufnr, query_group, root, lang)
180180
for _, maybe_match in pairs(matches) do
181-
local range = get_at_path(maybe_match, capture_string)
181+
local node = get_at_path(maybe_match, capture_string)
182+
---@cast node TSNode
183+
local range = { node:range(true) }
182184
---@cast range Range6
183185

184186
if range and filter_predicate(range) then

0 commit comments

Comments
 (0)