diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-02-15 11:35:54 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-02-15 11:35:54 +0000 |
commit | e3846cf1ebdc4af0b39885153b4703f71a9b919e (patch) | |
tree | d230fecced7b46f59c33a6120da05d0fd87a06bc /src/cmdexpand.c | |
parent | 8991be2ab4a9f3418ab41594a0c5b789c5cb0935 (diff) |
patch 8.2.4387: command line completion doesn't always work properlyv8.2.4387
Problem: Command line completion doesn't always work properly.
Solution: Adjust triggering after a "|". Add more tests. (Yegappan
Lakshmanan, closes #9779)
Diffstat (limited to 'src/cmdexpand.c')
-rw-r--r-- | src/cmdexpand.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 2a65a0691e..5cad1db2d7 100644 --- 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()); - } - // skip "to" part - while (arg[0] != NUL && arg[0] != delim) - { - if (arg[0] == '\\' && arg[1] != NUL) + + if (arg[0] != NUL && arg[0] == delim) + { + // skip "to" part ++arg; - ++arg; + while (arg[0] != NUL && arg[0] != delim) + { + if (arg[0] == '\\' && arg[1] != NUL) + ++arg; + ++arg; + } + if (arg[0] != NUL) // skip delimiter + ++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; } |