patch 9.1.1340: cannot complete :filetype arguments
Problem: cannot complete :filetype arguments (Phạm Bình An)
Solution: add :filetype ex command completion, add "filetypecmd"
completion type for getcompletion()
fixes: #17165
closes: #17167
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index c66a427..c4b7b57 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -684,6 +684,13 @@
let l = getcompletion('kill', 'expression')
call assert_equal([], l)
+ let l = getcompletion('', 'filetypecmd')
+ call assert_equal(["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('tag', 'function')
call assert_true(index(l, 'taglist(') >= 0)
let l = getcompletion('paint', 'function')
@@ -3209,6 +3216,26 @@
set wildoptions&
endfunc
+" :filetype suboptions completion
+func Test_completion_filetypecmd()
+ set wildoptions&
+ call feedkeys(":filetype \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"filetype indent off on plugin', @:)
+ 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')
+ call assert_equal('"filetype indent off on plugin', @:)
+ call feedkeys(":filetype i\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"filetype indent', @:)
+ call feedkeys(":filetype p\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"filetype plugin', @:)
+ call feedkeys(":filetype o\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"filetype off on', @:)
+ call feedkeys(":filetype indent of\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"filetype indent off', @:)
+ set wildoptions&
+endfunc
+
" " colorscheme name fuzzy completion - NOT supported
" func Test_fuzzy_completion_colorscheme()
" endfunc