mirror of
https://github.com/neovim/neovim.git
synced 2026-07-08 18:39:37 +00:00
[Backport release-0.9] fix: vim.treesitter.get_node() now correctly takes opts.lang (#26382)
[Backport release-0.9] fix(treesitter): allow passing lang to get_node()
This commit is contained in:
committed by
GitHub
parent
e7dc5dd69e
commit
8a4464cd14
@@ -40,6 +40,20 @@ describe('treesitter node API', function()
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('get_node() with lang given', function()
|
||||
-- this buffer doesn't have filetype set!
|
||||
insert('local foo = function() end')
|
||||
exec_lua([[
|
||||
node = vim.treesitter.get_node({
|
||||
bufnr = 0,
|
||||
pos = { 0, 6 }, -- on "foo"
|
||||
lang = 'lua',
|
||||
})
|
||||
]])
|
||||
eq('foo', lua_eval('vim.treesitter.query.get_node_text(node, 0)'))
|
||||
eq('identifier', lua_eval('node:type()'))
|
||||
end)
|
||||
|
||||
it('can move between siblings', function()
|
||||
insert([[
|
||||
int main(int x, int y, int z) {
|
||||
|
||||
Reference in New Issue
Block a user