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
This commit is contained in:
Stephan Seitz 2020-10-03 04:22:25 +02:00 committed by Thomas Vigouroux
parent e5d8b6ade7
commit 994e42fac4

View file

@ -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