summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2022-05-08 21:10:56 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-08 21:10:56 +0100
commitcb747899bd99361a299a163f3aa55d5fe7d6f798 (patch)
tree977d277555f886a24f18752d4cdee712c4e49023
parent8e8dc9b32326c6fbd37671b6072296404b481d4a (diff)
patch 8.2.4917: fuzzy expansion of option names is not rightv8.2.4917
Problem: Fuzzy expansion of option names is not right. Solution: Pass the fuzzy flag down the call chain. (Christian Brabandt, closes #10380, closes #10318)
-rw-r--r--src/cmdexpand.c2
-rw-r--r--src/option.c5
-rw-r--r--src/proto/option.pro2
-rw-r--r--src/testdir/test_options.vim22
-rw-r--r--src/version.c2
5 files changed, 29 insertions, 4 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index ea8dbfa14d..c3731cb645 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -2787,7 +2787,7 @@ ExpandFromContext(
if (xp->xp_context == EXPAND_SETTINGS
|| xp->xp_context == EXPAND_BOOL_SETTINGS)
- ret = ExpandSettings(xp, &regmatch, pat, numMatches, matches);
+ ret = ExpandSettings(xp, &regmatch, pat, numMatches, matches, fuzzy);
else if (xp->xp_context == EXPAND_MAPPINGS)
ret = ExpandMappings(pat, &regmatch, numMatches, matches);
# if defined(FEAT_EVAL)
diff --git a/src/option.c b/src/option.c
index 92b1b93fcd..33bb641b30 100644
--- a/src/option.c
+++ b/src/option.c
@@ -6511,7 +6511,8 @@ ExpandSettings(
regmatch_T *regmatch,
char_u *fuzzystr,
int *numMatches,
- char_u ***matches)
+ char_u ***matches,
+ int can_fuzzy)
{
int num_normal = 0; // Nr of matching non-term-code settings
int num_term = 0; // Nr of matching terminal code settings
@@ -6527,7 +6528,7 @@ ExpandSettings(
int fuzzy;
fuzmatch_str_T *fuzmatch = NULL;
- fuzzy = cmdline_fuzzy_complete(fuzzystr);
+ fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr);
// do this loop twice:
// loop == 0: count the number of matching options
diff --git a/src/proto/option.pro b/src/proto/option.pro
index 9425bc71d8..cef998b795 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -64,7 +64,7 @@ void reset_modifiable(void);
void set_iminsert_global(void);
void set_imsearch_global(void);
void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags);
-int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches);
+int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches, int do_fuzzy);
int ExpandOldSetting(int *num_file, char_u ***file);
int shortmess(int x);
void vimrc_found(char_u *fname, char_u *envname);
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index e49afae174..410d9461e3 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -1257,4 +1257,26 @@ func Test_opt_cdhome()
set cdhome&
endfunc
+func Test_set_completion_2()
+ CheckOption termguicolors
+
+ " Test default option completion
+ set wildoptions=
+ call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set termguicolors', @:)
+
+ call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set notermguicolors', @:)
+
+ " Test fuzzy option completion
+ set wildoptions=fuzzy
+ call feedkeys(":set termg\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set termguicolors termencoding', @:)
+
+ call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"set notermguicolors', @:)
+
+ set wildoptions=
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 4e7a335645..29cddd5139 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4917,
+/**/
4916,
/**/
4915,