mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
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:
@@ -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',
|
||||
|
Reference in New Issue
Block a user