Skip to content

Commit d5e8c92

Browse files
committed
patch 8.2.2452: no completion for the 'filetype' option
Problem: No completion for the 'filetype' option. Solution: Add filetype completion. (Martin Tournoij, closes #7747)
1 parent e7bebc4 commit d5e8c92

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/option.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,6 +2419,8 @@ was_set_insecurely(char_u *opt, int opt_flags)
24192419
/*
24202420
* Get a pointer to the flags used for the P_INSECURE flag of option
24212421
* "opt_idx". For some local options a local flags field is used.
2422+
* NOTE: Caller must make sure that "curwin" is set to the window from which
2423+
* the option is used.
24222424
*/
24232425
static long_u *
24242426
insecure_flag(int opt_idx, int opt_flags)
@@ -6209,6 +6211,10 @@ set_context_in_set_cmd(
62096211
else
62106212
xp->xp_backslash = XP_BS_ONE;
62116213
}
6214+
else if (p == (char_u *)&p_ft)
6215+
{
6216+
xp->xp_context = EXPAND_FILETYPE;
6217+
}
62126218
else
62136219
{
62146220
xp->xp_context = EXPAND_FILES;

src/optiondefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static struct vimoption options[] =
946946
(char_u *)FALSE,
947947
#endif
948948
(char_u *)0L} SCTX_INIT},
949-
{"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
949+
{"filetype", "ft", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
950950
(char_u *)&p_ft, PV_FT,
951951
{(char_u *)"", (char_u *)0L}
952952
SCTX_INIT},

src/testdir/test_options.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ func Test_set_completion()
332332
call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
333333
call assert_equal('"set key=*****', @:)
334334
set key=
335+
336+
" Expand values for 'filetype'
337+
call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
338+
call assert_equal('"set filetype=sshdconfig', @:)
339+
call feedkeys(":set filetype=a\<C-A>\<C-B>\"\<CR>", 'xt')
340+
call assert_equal('"set filetype=' .. getcompletion('a*', 'filetype')->join(), @:)
335341
endfunc
336342

337343
func Test_set_errors()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2452,
753755
/**/
754756
2451,
755757
/**/

0 commit comments

Comments
 (0)