]> granicus.if.org Git - vim/commitdiff
patch 8.2.2452: no completion for the 'filetype' option v8.2.2452
authorBram Moolenaar <Bram@vim.org>
Tue, 2 Feb 2021 20:10:01 +0000 (21:10 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 2 Feb 2021 20:10:01 +0000 (21:10 +0100)
Problem:    No completion for the 'filetype' option.
Solution:   Add filetype completion. (Martin Tournoij, closes #7747)

src/option.c
src/optiondefs.h
src/testdir/test_options.vim
src/version.c

index b4893a10ad3f57177194b2a412c54f7b2cd86d91..bba467e5e97f7e23f1e05b3f77cd0adb79760a04 100644 (file)
@@ -2419,6 +2419,8 @@ was_set_insecurely(char_u *opt, int opt_flags)
 /*
  * Get a pointer to the flags used for the P_INSECURE flag of option
  * "opt_idx".  For some local options a local flags field is used.
+ * NOTE: Caller must make sure that "curwin" is set to the window from which
+ * the option is used.
  */
     static long_u *
 insecure_flag(int opt_idx, int opt_flags)
@@ -6209,6 +6211,10 @@ set_context_in_set_cmd(
            else
                xp->xp_backslash = XP_BS_ONE;
        }
+       else if (p == (char_u *)&p_ft)
+       {
+           xp->xp_context = EXPAND_FILETYPE;
+       }
        else
        {
            xp->xp_context = EXPAND_FILES;
index 6cea0177cbcbda57149dc64ed50418add31919d8..9961bd4771d12b85f7c476fa2fd06fb215ae4367 100644 (file)
@@ -946,7 +946,7 @@ static struct vimoption options[] =
                                    (char_u *)FALSE,
 #endif
                                        (char_u *)0L} SCTX_INIT},
-    {"filetype",    "ft",   P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
+    {"filetype",    "ft",   P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
                            (char_u *)&p_ft, PV_FT,
                            {(char_u *)"", (char_u *)0L}
                            SCTX_INIT},
index c8b2700ddaa33d16ae764f2010d82d7a22e43da5..23e0de4377350ab437df2aa92d0bf9f019b7b044 100644 (file)
@@ -332,6 +332,12 @@ func Test_set_completion()
   call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"set key=*****', @:)
   set key=
+
+  " Expand values for 'filetype'
+  call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set filetype=sshdconfig', @:)
+  call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
 endfunc
 
 func Test_set_errors()
index cc8c728f928185cc580a0384b6abaf430c379622..c5f21db2c847577645540efa3446bfc5df63c74a 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2452,
 /**/
     2451,
 /**/