test(treesitter): coverage for comments with combined injections (#33975)

This commit is contained in:
Riley Bruins
2025-05-29 12:10:07 +02:00
committed by GitHub
parent 6c4ddf607f
commit cc264d51ab

View File

@@ -721,6 +721,39 @@ describe('commenting', function()
'EOF',
}, get_lines())
end)
it('works across combined injections #30799', function()
exec_lua [=[
vim.treesitter.query.set('lua', 'injections', [[
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments
(string
content: _ @injection.content)))
(#eq? @_vimcmd_identifier "vim.cmd")
(#set! injection.language "vim")
(#set! injection.combined))
]])
]=]
api.nvim_set_option_value('filetype', 'lua', { buf = 0 })
exec_lua('vim.treesitter.start()')
local lines = {
'vim.cmd([[" some text]])',
'local a = 123',
'vim.cmd([[" some more text]])',
}
set_lines(lines)
set_cursor(2, 0)
feed('gcc')
eq({
'vim.cmd([[" some text]])',
'-- local a = 123',
'vim.cmd([[" some more text]])',
}, get_lines())
end)
end)
describe('Textobject', function()