Skip to content

Commit 2ec2421

Browse files
ofseedclason
authored andcommitted
fix(shared): resolve metadata from directives
1 parent 35ef33c commit 2ec2421

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lua/nvim-treesitter-textobjects/shared.lua

+17-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,23 @@ local get_query_matches = memoize(function(bufnr, query_group, root, root_lang)
8888
if query_name ~= nil then
8989
local path = vim.split(query_name, "%.")
9090
for _, node in ipairs(nodes) do
91-
insert_to_path(prepared_match, path, { node:range(true) })
91+
local range = { node:range(true) }
92+
---@cast range Range6
93+
94+
-- Range could be changed by directives
95+
local node_data = metadata[id]
96+
if node_data and node_data.range then
97+
range = {
98+
node_data.range[1],
99+
node_data.range[2],
100+
range[3],
101+
node_data.range[3],
102+
node_data.range[4],
103+
range[6],
104+
}
105+
end
106+
107+
insert_to_path(prepared_match, path, range)
92108
end
93109
end
94110
end

0 commit comments

Comments
 (0)