From 0483ee825414ee02d0fc446c9bad4949b28e622f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 9 Dec 2022 09:45:45 +0800 Subject: vim-patch:8.2.4387: command line completion doesn't always work properly (#21352) Problem: Command line completion doesn't always work properly. Solution: Adjust triggering after a "|". Add more tests. (Yegappan Lakshmanan, closes vim/vim#9779) https://github.com/vim/vim/commit/e3846cf1ebdc4af0b39885153b4703f71a9b919e Co-authored-by: Yegappan Lakshmanan --- src/nvim/cmdexpand.c | 22 ++++--- src/nvim/testdir/test_cmdline.vim | 135 +++++++++++++++++++++++++++++++------- 2 files changed, 123 insertions(+), 34 deletions(-) (limited to 'src') 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; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index ebb3d4f0b3..c79aba810e 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -293,9 +293,6 @@ func Test_cmdheight_tabline() endfunc func Test_map_completion() - if !has('cmdline_compl') - return - endif call feedkeys(":map \\"\", 'xt') call assert_equal('"map ', getreg(':')) call feedkeys(":map