diff options
Diffstat (limited to 'src/nvim/cmdexpand.c')
-rw-r--r-- | src/nvim/cmdexpand.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 933ad93964..d1a56feef4 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1551,16 +1551,20 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons // Skip "from" part. arg++; arg = (const char *)skip_regexp((char *)arg, delim, magic_isset()); - } - // Skip "to" part. - while (arg[0] != NUL && (uint8_t)arg[0] != delim) { - if (arg[0] == '\\' && arg[1] != NUL) { + + if (arg[0] != NUL && arg[0] == delim) { + // Skip "to" part. arg++; + while (arg[0] != NUL && (uint8_t)arg[0] != delim) { + if (arg[0] == '\\' && arg[1] != NUL) { + arg++; + } + arg++; + } + if (arg[0] != NUL) { // Skip delimiter. + arg++; + } } - arg++; - } - if (arg[0] != NUL) { // Skip delimiter. - arg++; } while (arg[0] && strchr("|\"#", arg[0]) == NULL) { arg++; @@ -1591,7 +1595,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons arg = (const char *)skipwhite(arg + 1); // Check for trailing illegal characters. - if (*arg && strchr("|\"\n", *arg) == NULL) { + if (*arg == NUL || strchr("|\"\n", *arg) == NULL) { xp->xp_context = EXPAND_NOTHING; } else { return arg; |