diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-09-29 16:04:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 16:04:14 +0800 |
commit | 45707c1eae62667e5c482a09f6d9a62e01db0e21 (patch) | |
tree | 63fb5841b35a53b2b991f29a738c002fea28efa7 /test/functional/api/vim_spec.lua | |
parent | 1cf44d6f5794c7b6bd181dfb2ce51f5ff4381ee8 (diff) | |
download | rneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.tar.gz rneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.tar.bz2 rneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.zip |
fix(api): fix nvim_cmd crash with filename expansion (#20397)
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 44775ef85c..c2f3a5ec5e 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -14,6 +14,7 @@ local funcs = helpers.funcs local iswin = helpers.iswin local meths = helpers.meths local matches = helpers.matches +local pesc = helpers.pesc local mkdir_p = helpers.mkdir_p local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local is_os = helpers.is_os @@ -3912,11 +3913,23 @@ describe('API', function() eq({'aa'}, meths.buf_get_lines(0, 0, 1, false)) assert_alive() end) + it('supports filename expansion', function() + meths.cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {}) + local arg = funcs.expand('%:p:h:t') + eq({ arg, arg }, funcs.argv()) + end) it("'make' command works when argument count isn't 1 #19696", function() command('set makeprg=echo') - meths.cmd({ cmd = 'make' }, {}) + command('set shellquote=') + matches('^:!echo ', + meths.cmd({ cmd = 'make' }, { output = true })) + assert_alive() + matches('^:!echo foo bar', + meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true })) assert_alive() - meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, {}) + local arg_pesc = pesc(funcs.expand('%:p:h:t')) + matches(('^:!echo %s %s'):format(arg_pesc, arg_pesc), + meths.cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true })) assert_alive() end) it('doesn\'t display messages when output=true', function() |