From 14f3383c0da1413a5ae82feb19ac89f01d4b9aad Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sat, 7 May 2022 08:57:21 +0600 Subject: fix(api): make `nvim_parse_cmd` work correctly with both range and count It seems range and count can be used together in commands. This PR fixes the behavior of `nvim_parse_cmd` for those cases by removing the mutual exclusivity of "range" and "count". It also removes range line number validation for `nvim_parse_cmd` as it's not its job to validate the command. --- test/functional/api/vim_spec.lua | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'test/functional/api/vim_spec.lua') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 11c1fc6c2c..d68f299277 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3176,7 +3176,7 @@ describe('API', function() cmd = 'buffer', args = {}, bang = false, - range = {}, + range = { 1 }, count = 1, reg = '', addr = 'buf', @@ -3243,6 +3243,42 @@ describe('API', function() } }, meths.parse_cmd('put +', {})) end) + it('works with range, count and register', function() + eq({ + cmd = 'delete', + args = {}, + bang = false, + range = { 3, 7 }, + count = 7, + reg = '*', + addr = 'line', + magic = { + file = false, + bar = true + }, + nargs = '0', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = false, + hide = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + vertical = false, + split = "", + tab = 0, + verbose = -1 + } + }, meths.parse_cmd('1,3delete * 5', {})) + end) it('works with bang', function() eq({ cmd = 'write', -- cgit