aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/node_spec.lua
diff options
context:
space:
mode:
authorQuentin Rasmont <qrasmont@gmail.com>2022-05-01 21:13:47 +0200
committerbfredl <bjorn.linse@gmail.com>2022-08-25 18:01:14 +0200
commitf57341a4b69398ff0c58686e66c2f4138be164aa (patch)
tree4a017d046bab5680933b9499f9c831dfd42cebd6 /test/functional/treesitter/node_spec.lua
parentbaba43681e792db30318bdedc3e73e4fe12482a6 (diff)
downloadrneovim-f57341a4b69398ff0c58686e66c2f4138be164aa.tar.gz
rneovim-f57341a4b69398ff0c58686e66c2f4138be164aa.tar.bz2
rneovim-f57341a4b69398ff0c58686e66c2f4138be164aa.zip
feat(treesitter): upstream node_length() as a node method
Util from the nvim-treesitter project.
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r--test/functional/treesitter/node_spec.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua
index 9450526257..87ce1b973c 100644
--- a/test/functional/treesitter/node_spec.lua
+++ b/test/functional/treesitter/node_spec.lua
@@ -92,4 +92,20 @@ describe('treesitter node API', function()
eq(lua_eval('tostring(root)'), lua_eval('tostring(node:root())'))
end)
+
+ it('can compute the byte length of a node', function()
+ insert([[
+ int main() {
+ int x = 3;
+ }]])
+
+ exec_lua([[
+ tree = vim.treesitter.get_parser(0, "c"):parse()[1]
+ root = tree:root()
+ child = root:child(0):child(0)
+ ]])
+
+ eq(28, lua_eval('root:byte_length()'))
+ eq(3, lua_eval('child:byte_length()'))
+ end)
end)