test(treesitter): test tree:root() is idempotent

Test for regression #34605
This commit is contained in:
Rodrigodd
2025-06-28 16:28:51 -03:00
committed by Lewis Russell
parent 4eebc46930
commit 94f44d58fd

View File

@ -228,4 +228,17 @@ describe('treesitter node API', function()
end)
eq({ 0, 0, 2, 3 }, lua_eval('range'))
end)
it('tree:root() is idempotent', function()
insert([[
function x()
return true
end
]])
exec_lua(function()
local tree = vim.treesitter.get_parser(0, 'lua'):parse()[1]
assert(tree:root() == tree:root())
assert(tree:root() == tree:root():tree():root())
end)
end)
end)