mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(api): nvim_parse_cmd parses :map incorrectly #34068
Problem: nvim_parse_cmd() incorrectly splits mapping commands like into three arguments instead of preserving whitespace in the RHS. Solution: Add special handling for mapping commands to parse them as exactly two arguments - the LHS and the RHS with all whitespace preserved.
This commit is contained in:
@ -4641,6 +4641,45 @@ describe('API', function()
|
||||
},
|
||||
}, api.nvim_parse_cmd('argadd a.txt | argadd b.txt', {}))
|
||||
end)
|
||||
it('parses :map commands with space in RHS', function()
|
||||
eq({
|
||||
addr = 'none',
|
||||
args = { 'a', 'b c' },
|
||||
bang = false,
|
||||
cmd = 'map',
|
||||
magic = {
|
||||
bar = true,
|
||||
file = false,
|
||||
},
|
||||
mods = {
|
||||
browse = false,
|
||||
confirm = false,
|
||||
emsg_silent = false,
|
||||
filter = {
|
||||
force = false,
|
||||
pattern = '',
|
||||
},
|
||||
hide = false,
|
||||
horizontal = false,
|
||||
keepalt = false,
|
||||
keepjumps = false,
|
||||
keepmarks = false,
|
||||
keeppatterns = false,
|
||||
lockmarks = false,
|
||||
noautocmd = false,
|
||||
noswapfile = false,
|
||||
sandbox = false,
|
||||
silent = false,
|
||||
split = '',
|
||||
tab = -1,
|
||||
unsilent = false,
|
||||
verbose = -1,
|
||||
vertical = false,
|
||||
},
|
||||
nargs = '*',
|
||||
nextcmd = '',
|
||||
}, api.nvim_parse_cmd('map a b c', {}))
|
||||
end)
|
||||
it('works for nargs=1', function()
|
||||
command('command -nargs=1 MyCommand echo <q-args>')
|
||||
eq({
|
||||
|
Reference in New Issue
Block a user