diff options
author | Riley Bruins <ribru17@hotmail.com> | 2024-05-14 07:14:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 09:14:43 -0500 |
commit | 6a264e08974bcb1b91f891eb65ef374f350d2827 (patch) | |
tree | a205375bf1d1aba5ccedd0003707097e25f6c0ee /test/functional | |
parent | 6818ba271cb43b1430f019b832d7e26671e0f5f4 (diff) | |
download | rneovim-6a264e08974bcb1b91f891eb65ef374f350d2827.tar.gz rneovim-6a264e08974bcb1b91f891eb65ef374f350d2827.tar.bz2 rneovim-6a264e08974bcb1b91f891eb65ef374f350d2827.zip |
fix(treesitter): allow optional directive captures (#28664)
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/treesitter/parser_spec.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index 1166166530..dbd6bb3c23 100644 --- a/test/functional/treesitter/parser_spec.lua +++ b/test/functional/treesitter/parser_spec.lua @@ -547,6 +547,36 @@ int x = INT_MAX; end) end) + describe('when setting the node for an injection', function() + before_each(function() + insert([[ +print() + ]]) + end) + + it('ignores optional captures #23100', function() + local result = exec_lua([[ + parser = vim.treesitter.get_parser(0, "lua", { + injections = { + lua = ( + '(function_call ' .. + '(arguments ' .. + '(string)? @injection.content ' .. + '(number)? @injection.content ' .. + '(#offset! @injection.content 0 1 0 -1) ' .. + '(#set! injection.language "c")))' + ) + } + }) + parser:parse(true) + + return parser:is_valid() + ]]) + + eq(true, result) + end) + end) + describe('when getting/setting match data', function() describe('when setting for the whole match', function() it('should set/get the data correctly', function() |