Skip to content

Commit f14de22

Browse files
committed
refactor: save TSNode directly
1 parent d675d10 commit f14de22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lua/nvim-treesitter-textobjects/shared.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ local function get_capture_ranges_recursively(bufnr, query_string, query_group)
150150
for _, match in pairs(matches) do
151151
local found = get_at_path(match, query_string)
152152
if found then
153-
---@cast found Range6
154-
table.insert(ranges, found)
153+
---@cast found TSNode
154+
table.insert(ranges, { found:range(true) })
155155
end
156156
end
157157
end)
@@ -185,7 +185,9 @@ function M.find_best_range(bufnr, capture_string, query_group, filter_predicate,
185185

186186
local matches = get_query_matches(bufnr, query_group, root, lang)
187187
for _, maybe_match in pairs(matches) do
188-
local range = get_at_path(maybe_match, capture_string)
188+
local node = get_at_path(maybe_match, capture_string)
189+
---@cast node TSNode
190+
local range = { node:range(true) }
189191
---@cast range Range6
190192

191193
if range and filter_predicate(range) then

0 commit comments

Comments
 (0)