From 994e42fac46399969e4032ffe9815ac727db5514 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 3 Oct 2020 04:22:25 +0200 Subject: Fix: avoid overwriting tables in insert_to_path The following query will result in matches with only one node though it requires two nodes to be a match. ```scheme (function_definition (comment) @function.inner.start body: (block) @function.inner) ``` Why? First `insert_to_path` is called for `@function.inner.start` which will result int the following table. ```lua { function = { inner = { start { node } } } } ``` `insert_to_path` will overwrite the result ```lua { function = { inner = { node } } } ``` Related #552 --- lua/nvim-treesitter/query.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua index 8a1722a3c..3b3b171ad 100644 --- a/lua/nvim-treesitter/query.lua +++ b/lua/nvim-treesitter/query.lua @@ -85,8 +85,8 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) for id, node in pairs(match) do local name = query.captures[id] -- name of the capture in the query if name ~= nil then - local path = split(name) - insert_to_path(prepared_match, path, { node=node }) + local path = split(name..'.node') + insert_to_path(prepared_match, path, node) end end -- cgit v1.2.3-70-g09d2