From 4abafefee5f90207e9213a4995ce9cc8dd34d41c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 Jun 2026 08:25:37 +0800 Subject: [PATCH] vim-patch:9.2.0726: filetype detect missing from completion (#40439) Problem: ":filetype detect" is a valid command but not offered by command-line completion. Solution: Add "detect" to the completion candidates (glepnir) closes: vim/vim#20625 https://github.com/vim/vim/commit/984f29860ed4e7259de932ca7a8027e650efae7a Co-authored-by: glepnir --- src/nvim/cmdexpand.c | 4 ++-- test/old/testdir/test_cmdline.vim | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 960f1ef9f5..8af6fbd536 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2790,8 +2790,8 @@ static char *get_filetypecmd_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) return NULL; } - if (filetype_expand_what == EXP_FILETYPECMD_ALL && idx < 4) { - char *opts_all[] = { "indent", "plugin", "on", "off" }; + if (filetype_expand_what == EXP_FILETYPECMD_ALL && idx < 5) { + char *opts_all[] = { "detect", "indent", "plugin", "on", "off" }; return opts_all[idx]; } if (filetype_expand_what == EXP_FILETYPECMD_PLUGIN && idx < 3) { diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 0008c4b4bf..7399f99c5b 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -560,11 +560,13 @@ func Test_getcompletion() call assert_equal([], l) let l = getcompletion('', 'filetypecmd') - call assert_equal(["indent", "off", "on", "plugin"], l) + call assert_equal(["detect", "indent", "off", "on", "plugin"], l) let l = getcompletion('not', 'filetypecmd') call assert_equal([], l) let l = getcompletion('o', 'filetypecmd') call assert_equal(['off', 'on'], l) + let l = getcompletion('det', 'filetypecmd') + call assert_equal(['detect'], l) let l = getcompletion('tag', 'function') call assert_true(index(l, 'taglist(') >= 0) @@ -3581,7 +3583,9 @@ endfunc func Test_completion_filetypecmd() set wildoptions& call feedkeys(":filetype \\\"\", 'tx') - call assert_equal('"filetype indent off on plugin', @:) + call assert_equal('"filetype detect indent off on plugin', @:) + call feedkeys(":filetype det\\\"\", 'tx') + call assert_equal('"filetype detect', @:) call feedkeys(":filetype plugin \\\"\", 'tx') call assert_equal('"filetype plugin indent off on', @:) call feedkeys(":filetype indent \\\"\", 'tx')