Mercurial > vim
diff src/cmdexpand.c @ 27722:637ccebaf328 v8.2.4387
patch 8.2.4387: command line completion doesn't always work properly
Commit: https://github.com/vim/vim/commit/e3846cf1ebdc4af0b39885153b4703f71a9b919e
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Feb 15 11:35:54 2022 +0000
patch 8.2.4387: command line completion doesn't always work properly
Problem: Command line completion doesn't always work properly.
Solution: Adjust triggering after a "|". Add more tests. (Yegappan
Lakshmanan, closes #9779)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 15 Feb 2022 12:45:04 +0100 |
parents | 38eab98ef5a9 |
children | 515ce8e07bf2 |
line wrap: on
line diff
--- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -1473,16 +1473,21 @@ set_context_by_cmdname( // skip "from" part ++arg; arg = skip_regexp(arg, delim, magic_isset()); + + if (arg[0] != NUL && arg[0] == delim) + { + // skip "to" part + ++arg; + while (arg[0] != NUL && arg[0] != delim) + { + if (arg[0] == '\\' && arg[1] != NUL) + ++arg; + ++arg; + } + if (arg[0] != NUL) // skip delimiter + ++arg; + } } - // skip "to" part - while (arg[0] != NUL && arg[0] != delim) - { - if (arg[0] == '\\' && arg[1] != NUL) - ++arg; - ++arg; - } - if (arg[0] != NUL) // skip delimiter - ++arg; while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) ++arg; if (arg[0] != NUL) @@ -1508,7 +1513,8 @@ set_context_by_cmdname( arg = skipwhite(arg + 1); // Check for trailing illegal characters - if (*arg && vim_strchr((char_u *)"|\"\n", *arg) == NULL) + if (*arg == NUL || + vim_strchr((char_u *)"|\"\n", *arg) == NULL) xp->xp_context = EXPAND_NOTHING; else return arg; @@ -2408,6 +2414,8 @@ ExpandFromContext( int len = (int)STRLEN(pat) + 20; tofree = alloc(len); + if (tofree == NULL) + return FAIL; vim_snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3); pat = tofree; }