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.
This commit is contained in:
Famiu Haque
2022-05-07 08:57:21 +06:00
parent b2a8ed0855
commit 14f3383c0d
4 changed files with 45 additions and 10 deletions

View File

@@ -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',