aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/command.c7
-rw-r--r--test/functional/api/vim_spec.lua7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index bc766ff39c..fc1f6a04f2 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -819,9 +819,12 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
char *p = replace_makeprg(eap, eap->arg, cmdlinep);
if (p != eap->arg) {
// If replace_makeprg modified the cmdline string, correct the argument pointers.
- assert(argc == 1);
eap->arg = p;
- eap->args[0] = p;
+ // We can only know the position of the first argument because the argument list can be used
+ // multiple times in makeprg / grepprg.
+ if (argc >= 1) {
+ eap->args[0] = p;
+ }
}
}
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index fe623ff824..3338fc6538 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3829,5 +3829,12 @@ describe('API', function()
eq({'aa'}, meths.buf_get_lines(0, 0, 1, false))
assert_alive()
end)
+ it("'make' command works when argument count isn't 1 #19696", function()
+ command('set makeprg=echo')
+ meths.cmd({ cmd = 'make' }, {})
+ assert_alive()
+ meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, {})
+ assert_alive()
+ end)
end)
end)