diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-10-03 04:22:25 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-10-16 13:48:59 +0200 |
| commit | 994e42fac46399969e4032ffe9815ac727db5514 (patch) | |
| tree | 4a308c4324b87ff8b4b29f51346255ffbca6b23e | |
| parent | Remove get_parser logic (diff) | |
| download | nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar.gz nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar.bz2 nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar.lz nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar.xz nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.tar.zst nvim-treesitter-994e42fac46399969e4032ffe9815ac727db5514.zip | |
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
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 4 |
1 files changed, 2 insertions, 2 deletions
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 |
