Skip to content

Commit d35952c

Browse files
committed
refactor: save TSNode directly
1 parent 5c6db01 commit d35952c

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
@@ -159,8 +159,8 @@ local function get_capture_ranges_recursively(bufnr, query_string, query_group)
159159
for _, match in pairs(matches) do
160160
local found = get_at_path(match, query_string)
161161
if found then
162-
---@cast found Range6
163-
table.insert(ranges, found)
162+
---@cast found TSNode
163+
table.insert(ranges, { found:range(true) })
164164
end
165165
end
166166
end)
@@ -194,7 +194,9 @@ function M.find_best_range(bufnr, capture_string, query_group, filter_predicate,
194194

195195
local matches = get_query_matches(bufnr, query_group, root, lang)
196196
for _, maybe_match in pairs(matches) do
197-
local range = get_at_path(maybe_match, capture_string)
197+
local node = get_at_path(maybe_match, capture_string)
198+
---@cast node TSNode
199+
local range = { node:range(true) }
198200
---@cast range Range6
199201

200202
if range and filter_predicate(range) then

0 commit comments

Comments
 (0)