From f14de229846a99bac7e657b3f043adbacc635570 Mon Sep 17 00:00:00 2001 From: Yi Ming Date: Sun, 8 Sep 2024 06:50:10 +0800 Subject: [PATCH] refactor: save `TSNode` directly --- lua/nvim-treesitter-textobjects/shared.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/nvim-treesitter-textobjects/shared.lua b/lua/nvim-treesitter-textobjects/shared.lua index a1cf901e..452cbf29 100644 --- a/lua/nvim-treesitter-textobjects/shared.lua +++ b/lua/nvim-treesitter-textobjects/shared.lua @@ -150,8 +150,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) @@ -185,7 +185,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