From cc264d51aba802d7f536cc3680b3af2d13ed1889 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Thu, 29 May 2025 12:10:07 +0200 Subject: [PATCH] test(treesitter): coverage for comments with combined injections (#33975) --- test/functional/lua/comment_spec.lua | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua index 3284276b32..518abc84dd 100644 --- 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()