Skip to content

Commit cb74789

Browse files
chrisbrabrammool
authored andcommitted
patch 8.2.4917: fuzzy expansion of option names is not right
Problem: Fuzzy expansion of option names is not right. Solution: Pass the fuzzy flag down the call chain. (Christian Brabandt, closes #10380, closes #10318)
1 parent 8e8dc9b commit cb74789

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

src/cmdexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ ExpandFromContext(
27872787

27882788
if (xp->xp_context == EXPAND_SETTINGS
27892789
|| xp->xp_context == EXPAND_BOOL_SETTINGS)
2790-
ret = ExpandSettings(xp, &regmatch, pat, numMatches, matches);
2790+
ret = ExpandSettings(xp, &regmatch, pat, numMatches, matches, fuzzy);
27912791
else if (xp->xp_context == EXPAND_MAPPINGS)
27922792
ret = ExpandMappings(pat, &regmatch, numMatches, matches);
27932793
# if defined(FEAT_EVAL)

src/option.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6511,7 +6511,8 @@ ExpandSettings(
65116511
regmatch_T *regmatch,
65126512
char_u *fuzzystr,
65136513
int *numMatches,
6514-
char_u ***matches)
6514+
char_u ***matches,
6515+
int can_fuzzy)
65156516
{
65166517
int num_normal = 0; // Nr of matching non-term-code settings
65176518
int num_term = 0; // Nr of matching terminal code settings
@@ -6527,7 +6528,7 @@ ExpandSettings(
65276528
int fuzzy;
65286529
fuzmatch_str_T *fuzmatch = NULL;
65296530

6530-
fuzzy = cmdline_fuzzy_complete(fuzzystr);
6531+
fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr);
65316532

65326533
// do this loop twice:
65336534
// loop == 0: count the number of matching options

src/proto/option.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void reset_modifiable(void);
6464
void set_iminsert_global(void);
6565
void set_imsearch_global(void);
6666
void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags);
67-
int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches);
67+
int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches, int do_fuzzy);
6868
int ExpandOldSetting(int *num_file, char_u ***file);
6969
int shortmess(int x);
7070
void vimrc_found(char_u *fname, char_u *envname);

src/testdir/test_options.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,4 +1257,26 @@ func Test_opt_cdhome()
12571257
set cdhome&
12581258
endfunc
12591259

1260+
func Test_set_completion_2()
1261+
CheckOption termguicolors
1262+
1263+
" Test default option completion
1264+
set wildoptions=
1265+
call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
1266+
call assert_equal('"set termguicolors', @:)
1267+
1268+
call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
1269+
call assert_equal('"set notermguicolors', @:)
1270+
1271+
" Test fuzzy option completion
1272+
set wildoptions=fuzzy
1273+
call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
1274+
call assert_equal('"set termguicolors termencoding', @:)
1275+
1276+
call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
1277+
call assert_equal('"set notermguicolors', @:)
1278+
1279+
set wildoptions=
1280+
endfunc
1281+
12601282
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

747747
static int included_patches[] =
748748
{ /* Add new patch number below this line */
749+
/**/
750+
4917,
749751
/**/
750752
4916,
751753
/**/

0 commit comments

Comments
 (0)