Commit: patch 9.2.0508: completion: cannot complete user cmd :K with 'ignorecase'

1 view
Skip to first unread message

Christian Brabandt

unread,
May 21, 2026, 4:15:12 PM (17 hours ago) May 21
to vim...@googlegroups.com
patch 9.2.0508: completion: cannot complete user cmd :K with 'ignorecase'

Commit: https://github.com/vim/vim/commit/b54e57ee54f0a4e6eac74b071071a9d85326de3a
Author: Yasuhiro Matsumoto <matt...@gmail.com>
Date: Thu May 21 19:57:06 2026 +0000

patch 9.2.0508: completion: cannot complete user cmd :K with 'ignorecase'

Problem: completion: cannot complete user cmd :K with 'ignorecase'
(rendcrx)
Solution: Skip the short-circuit when 'ignorecase' is set
(Yasuhiro Matsumoto)

The set_cmd_index() short-circuit for the :k command treats ":k<X>" as
":k {X}" (mark argument), which makes ":kz<Tab>" never reach the
command-name expansion path. With 'ignorecase' the same prefix on other
letters (":gz<Tab>") completes a user command like :Gz, so the result is
inconsistent. Skip the short-circuit when 'ignorecase' is set; default
behaviour is preserved so the existing :k tests still pass.

fixes: #20241
closes: #20275

Co-authored-by: zeertzjq <zeer...@outlook.com>
Signed-off-by: Yasuhiro Matsumoto <matt...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 19ae31998..8d9c2d7b7 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -1759,11 +1759,12 @@ set_cmd_index(char_u *cmd, exarg_T *eap, expand_T *xp, int *complp)
// Isolate the command and search for it in the command table.
// Exceptions:
// - the 'k' command can directly be followed by any character, but do
- // accept "keepmarks", "keepalt" and "keepjumps". As fuzzy matching can
- // find matches anywhere in the command name, do this only for command
- // expansion based on regular expression and not for fuzzy matching.
+ // accept "keepmarks", "keepalt" and "keepjumps". Bypass also when
+ // 'ignorecase' is set so a lowercase ":kz" still completes a user
+ // command like :Kz (#20241), and for fuzzy matching as that can find
+ // matches anywhere in the command name.
// - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
- if (!fuzzy && (*cmd == 'k' && cmd[1] != 'e'))
+ if (!fuzzy && !p_ic && (*cmd == 'k' && cmd[1] != 'e'))
{
eap->cmdidx = CMD_k;
p = cmd + 1;
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 7c1365b6a..31fb1f8ff 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -4095,6 +4095,27 @@ func Test_fuzzy_completion_cmd_k()
set wildoptions&
endfunc

+" Issue #20241: with 'ignorecase', a lowercase "k"-prefixed input should
+" still complete a user command starting with "K".
+func Test_cmdline_complete_user_cmd_k_with_ignorecase()
+ command! Kz echo "hello"
+ command! Gz echo "here"
+
+ set noignorecase
+ call assert_equal([], getcompletion('kz', 'cmdline'))
+ call assert_equal([], getcompletion('gz', 'cmdline'))
+ call assert_equal(['Kz'], getcompletion('Kz', 'cmdline'))
+ call assert_equal(['Gz'], getcompletion('Gz', 'cmdline'))
+
+ set ignorecase
+ call assert_equal(['Kz'], getcompletion('kz', 'cmdline'))
+ call assert_equal(['Gz'], getcompletion('gz', 'cmdline'))
+
+ set ignorecase&
+ delcommand Kz
+ delcommand Gz
+endfunc
+
" Test for fuzzy completion for user defined custom completion function
func Test_fuzzy_completion_custom_func()
func Tcompl(a, c, p)
diff --git a/src/version.c b/src/version.c
index 863043dab..40b26d7cf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 508,
/**/
507,
/**/
Reply all
Reply to author
Forward
0 new messages