aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2022-05-11 22:51:53 +0600
committerGitHub <noreply@github.com>2022-05-11 10:51:53 -0600
commitcf68f0a51202342163825015602bdf78b783c777 (patch)
treead2c5b94cc178fdfef7b276db19dfe1bce978d0d /src/nvim/api/private/helpers.c
parenta6f4cfdefa6937b7a0a364277a8157d483631f6d (diff)
downloadrneovim-cf68f0a51202342163825015602bdf78b783c777.tar.gz
rneovim-cf68f0a51202342163825015602bdf78b783c777.tar.bz2
rneovim-cf68f0a51202342163825015602bdf78b783c777.zip
fix(api): make `nvim_cmd` work correctly with empty arguments list (#18527)
Closes #18526.
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index ccf1896f08..542e5c4953 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -1843,7 +1843,8 @@ int build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdinfo, char
CMDLINE_APPEND(" %s", args[i]);
}
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'.
char *p = replace_makeprg(eap, eap->arg, cmdlinep);