diff options
author | Riley Bruins <ribru17@hotmail.com> | 2024-07-28 13:23:40 -0700 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-07-29 17:15:46 +0200 |
commit | bd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e (patch) | |
tree | f30673b516bd052b08ec38fb47dc715ef2e8406a /test/functional/treesitter/language_spec.lua | |
parent | 01a56a056cd5da89350583ef9fbc97fa29dcd8ef (diff) | |
download | rneovim-bd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e.tar.gz rneovim-bd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e.tar.bz2 rneovim-bd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e.zip |
feat(treesitter): add node_for_range function
This is identical to `named_node_for_range` except that it includes
anonymous nodes. This maintains consistency in the API because we
already have `descendant_for_range` and `named_descendant_for_range`.
Diffstat (limited to 'test/functional/treesitter/language_spec.lua')
-rw-r--r-- | test/functional/treesitter/language_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/treesitter/language_spec.lua b/test/functional/treesitter/language_spec.lua index 40c974beee..e71c39244f 100644 --- a/test/functional/treesitter/language_spec.lua +++ b/test/functional/treesitter/language_spec.lua @@ -148,4 +148,15 @@ describe('treesitter language API', function() eq('<node primitive_type>', exec_lua('return tostring(node)')) end) + + it('retrieve an anonymous node given a range', function() + insert([[vim.fn.input()]]) + + exec_lua([[ + langtree = vim.treesitter.get_parser(0, "lua") + node = langtree:node_for_range({0, 3, 0, 3}) + ]]) + + eq('.', exec_lua('return node:type()')) + end) end) |