vim-patch:9.2.0683: filetype completion mishandles finished sub options (#40351)

Problem:  ":filetype plugin<Tab>" 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

fe65f23aca

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2026-06-21 22:16:03 +08:00
committed by GitHub
parent 9607e53cea
commit dc0b54276d
2 changed files with 6 additions and 2 deletions

View File

@@ -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;

View File

@@ -3585,6 +3585,10 @@ func Test_completion_filetypecmd()
call assert_equal('"filetype off on', @:)
call feedkeys(":filetype indent of\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype indent off', @:)
call feedkeys(":filetype plugin\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype plugin', @:)
call feedkeys(":filetype plugin indent\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"filetype plugin indent', @:)
set wildoptions&
endfunc