mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
fix(api): make nvim_cmd
work correctly with empty arguments list (#18527)
Closes #18526.
This commit is contained in:
@@ -1843,7 +1843,8 @@ int build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdinfo, char
|
|||||||
CMDLINE_APPEND(" %s", args[i]);
|
CMDLINE_APPEND(" %s", args[i]);
|
||||||
}
|
}
|
||||||
eap->argc = argc;
|
eap->argc = argc;
|
||||||
eap->arg = argc > 0 ? eap->args[0] : NULL;
|
// If there isn't an argument, make eap->arg point to end of cmd
|
||||||
|
eap->arg = argc > 0 ? eap->args[0] : cmdline + pos;
|
||||||
|
|
||||||
// Replace, :make and :grep with 'makeprg' and 'grepprg'.
|
// Replace, :make and :grep with 'makeprg' and 'grepprg'.
|
||||||
char *p = replace_makeprg(eap, eap->arg, cmdlinep);
|
char *p = replace_makeprg(eap, eap->arg, cmdlinep);
|
||||||
|
@@ -3615,5 +3615,9 @@ describe('API', function()
|
|||||||
it('errors if command is not implemented', function()
|
it('errors if command is not implemented', function()
|
||||||
eq("Command not implemented: popup", pcall_err(meths.cmd, { cmd = "popup" }, {}))
|
eq("Command not implemented: popup", pcall_err(meths.cmd, { cmd = "popup" }, {}))
|
||||||
end)
|
end)
|
||||||
|
it('works with empty arguments list', function()
|
||||||
|
meths.cmd({ cmd = "update" }, {})
|
||||||
|
meths.cmd({ cmd = "buffer", count = 0 }, {})
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user