From dc0b54276da63f4f2be3260df441b1931ade5aba Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 21 Jun 2026 22:16:03 +0800 Subject: [PATCH] vim-patch:9.2.0683: filetype completion mishandles finished sub options (#40351) Problem: ":filetype plugin" gives "pluginindent" because a sub option before the cursor is treated as already given. Solution: only skip plugin and indent when followed by white space. (glepnir) closes: vim/vim#20594 https://github.com/vim/vim/commit/fe65f23aca22c40d5e919aa0e4f2909bf57d8d94 Co-authored-by: glepnir --- src/nvim/cmdexpand.c | 4 ++-- test/old/testdir/test_cmdline.vim | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 439c1217f0..960f1ef9f5 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1957,12 +1957,12 @@ static const char *set_context_in_filetype_cmd(expand_T *xp, const char *arg) int val = 0; while (true) { - if (strncmp(p, "plugin", 6) == 0) { + if (strncmp(p, "plugin", 6) == 0 && ascii_iswhite(p[6])) { val |= EXPAND_FILETYPECMD_PLUGIN; p = skipwhite(p + 6); continue; } - if (strncmp(p, "indent", 6) == 0) { + if (strncmp(p, "indent", 6) == 0 && ascii_iswhite(p[6])) { val |= EXPAND_FILETYPECMD_INDENT; p = skipwhite(p + 6); continue; diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index a0c887347f..6dd7543a2f 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -3585,6 +3585,10 @@ func Test_completion_filetypecmd() call assert_equal('"filetype off on', @:) call feedkeys(":filetype indent of\\\"\", 'tx') call assert_equal('"filetype indent off', @:) + call feedkeys(":filetype plugin\\\"\", 'tx') + call assert_equal('"filetype plugin', @:) + call feedkeys(":filetype plugin indent\\\"\", 'tx') + call assert_equal('"filetype plugin indent', @:) set wildoptions& endfunc