diff options
| author | Riley Bruins <ribru17@hotmail.com> | 2024-09-19 13:08:22 -0700 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-10-11 18:15:07 +0200 |
| commit | d3193afc2559e7d84ed2d76664a650dc03b4c6ef (patch) | |
| tree | cfa3e37e11d158713ae01a691e03853509317e39 /test/functional/treesitter/parser_spec.lua | |
| parent | 267c7525f738cdd6024c39da758e885c026ffaaa (diff) | |
| download | rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.tar.gz rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.tar.bz2 rneovim-d3193afc2559e7d84ed2d76664a650dc03b4c6ef.zip | |
fix(treesitter): remove duplicate symbol names in language.inspect()
**Problems:**
- `vim.treesitter.language.inspect()` returns duplicate
symbol names, sometimes up to 6 of one kind in the case of `markdown`
- The list-like `symbols` table can have holes and is thus not even a
valid msgpack table anyway, mentioned in a test
**Solution:** Return symbols as a map, rather than a list, where field
names are the names of the symbol. The boolean value associated with the
field encodes whether or not the symbol is named.
Note that anonymous nodes are surrounded with double quotes (`"`) to
prevent potential collisions with named counterparts that have the same
identifier.
Diffstat (limited to 'test/functional/treesitter/parser_spec.lua')
| -rw-r--r-- | test/functional/treesitter/parser_spec.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index c8829f4785..2f8d204d36 100644 --- a/test/functional/treesitter/parser_spec.lua +++ b/test/functional/treesitter/parser_spec.lua @@ -42,13 +42,13 @@ describe('treesitter parser API', function() eq('function_definition', exec_lua('return child:type()')) eq(true, exec_lua('return child:named()')) eq('number', type(exec_lua('return child:symbol()'))) - eq({ 'function_definition', true }, exec_lua('return lang.symbols[child:symbol()]')) + eq(true, exec_lua('return lang.symbols[child:type()]')) exec_lua('anon = root:descendant_for_range(0,8,0,9)') eq('(', exec_lua('return anon:type()')) eq(false, exec_lua('return anon:named()')) eq('number', type(exec_lua('return anon:symbol()'))) - eq({ '(', false }, exec_lua('return lang.symbols[anon:symbol()]')) + eq(false, exec_lua([=[return lang.symbols[string.format('"%s"', anon:type())]]=])) exec_lua('descendant = root:descendant_for_range(1,2,1,12)') eq('<node declaration>', exec_lua('return tostring(descendant)')) |