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

984f29860e

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2026-06-27 08:25:37 +08:00
committed by GitHub
parent 4de7038762
commit 4abafefee5
2 changed files with 8 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype indent off on plugin', @:)
call assert_equal('"filetype detect indent off on plugin', @:)
call feedkeys(":filetype det\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype detect', @:)
call feedkeys(":filetype plugin \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype plugin indent off on', @:)
call feedkeys(":filetype indent \<C-A>\<C-B>\"\<CR>", 'tx')