commit cc264d51aba802d7f536cc3680b3af2d13ed1889
parent 6c4ddf607f0b0b4b72c4a949d796853aa77db08f
Author: Riley Bruins <ribru17@hotmail.com>
Date: Thu, 29 May 2025 12:10:07 +0200
test(treesitter): coverage for comments with combined injections (#33975)
Diffstat:
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua
@@ -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()