vim-patch:8.2.2452: no completion for the 'filetype' option

Problem:    No completion for the 'filetype' option.
Solution:   Add filetype completion. (Martin Tournoij, closes vim/vim#7747)
d5e8c92816
This commit is contained in:
Jan Edmund Lazo
2021-03-12 18:38:12 -05:00
parent ea99cbc85a
commit b650d2d8d9
3 changed files with 15 additions and 1 deletions

View File

@@ -2086,9 +2086,12 @@ int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags)
/// Get a pointer to the flags used for the P_INSECURE flag of option /// 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. /// "opt_idx". For some local options a local flags field is used.
/// NOTE: Caller must make sure that "wp" is set to the window from which
/// the option is used.
static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags) static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
{ {
if (opt_flags & OPT_LOCAL) if (opt_flags & OPT_LOCAL) {
assert(wp != NULL);
switch ((int)options[opt_idx].indir) { switch ((int)options[opt_idx].indir) {
case PV_STL: return &wp->w_p_stl_flags; case PV_STL: return &wp->w_p_stl_flags;
case PV_FDE: return &wp->w_p_fde_flags; case PV_FDE: return &wp->w_p_fde_flags;
@@ -2097,6 +2100,7 @@ static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
case PV_FEX: return &wp->w_buffer->b_p_fex_flags; case PV_FEX: return &wp->w_buffer->b_p_fex_flags;
case PV_INEX: return &wp->w_buffer->b_p_inex_flags; case PV_INEX: return &wp->w_buffer->b_p_inex_flags;
} }
}
// Nothing special, return global flags field. // Nothing special, return global flags field.
return &options[opt_idx].flags; return &options[opt_idx].flags;
@@ -6178,6 +6182,8 @@ set_context_in_set_cmd(
xp->xp_backslash = XP_BS_THREE; xp->xp_backslash = XP_BS_THREE;
else else
xp->xp_backslash = XP_BS_ONE; xp->xp_backslash = XP_BS_ONE;
} else if (p == (char_u *)&p_ft) {
xp->xp_context = EXPAND_FILETYPE;
} else { } else {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
// for 'tags' need three backslashes for a space // for 'tags' need three backslashes for a space

View File

@@ -900,6 +900,7 @@ return {
normal_fname_chars=true, normal_fname_chars=true,
vi_def=true, vi_def=true,
alloced=true, alloced=true,
expand=true,
varname='p_ft', varname='p_ft',
defaults={if_true={vi=""}} defaults={if_true={vi=""}}
}, },

View File

@@ -230,6 +230,13 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:) call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
set tags& set tags&
" 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(), @:)
call assert_equal('"set filetype=' .. join(getcompletion('a*', 'filetype')), @:)
endfunc endfunc
func Test_set_errors() func Test_set_errors()