diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-17 16:46:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 16:46:43 +0800 |
commit | 58f2dcfc887134f5ebc33c13d7ef5ce540f8a247 (patch) | |
tree | aad572de34e928784e2164d1425352bb8882646d | |
parent | 8abf53be6e2aa92a60220a11c2a5ad6d9b364235 (diff) | |
download | rneovim-58f2dcfc887134f5ebc33c13d7ef5ce540f8a247.tar.gz rneovim-58f2dcfc887134f5ebc33c13d7ef5ce540f8a247.tar.bz2 rneovim-58f2dcfc887134f5ebc33c13d7ef5ce540f8a247.zip |
vim-patch:8.2.4917: fuzzy expansion of option names is not right (#21853)
Problem: Fuzzy expansion of option names is not right.
Solution: Pass the fuzzy flag down the call chain. (Christian Brabandt,
closes vim/vim#10380, closes vim/vim#10318)
https://github.com/vim/vim/commit/cb747899bd99361a299a163f3aa55d5fe7d6f798
Co-authored-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/nvim/cmdexpand.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_options.vim | 24 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index ef64bf90fa..21b9eb1f56 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2729,7 +2729,7 @@ static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numM if (xp->xp_context == EXPAND_SETTINGS || xp->xp_context == EXPAND_BOOL_SETTINGS) { - ret = ExpandSettings(xp, ®match, pat, numMatches, matches); + ret = ExpandSettings(xp, ®match, pat, numMatches, matches, fuzzy); } else if (xp->xp_context == EXPAND_MAPPINGS) { ret = ExpandMappings(pat, ®match, numMatches, matches); } else if (xp->xp_context == EXPAND_USER_DEFINED) { diff --git a/src/nvim/option.c b/src/nvim/option.c index aec91a4dc6..024bf3af09 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4740,7 +4740,7 @@ static bool match_str(char *const str, regmatch_T *const regmatch, char **const } int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char *fuzzystr, int *numMatches, - char ***matches) + char ***matches, const bool can_fuzzy) { int num_normal = 0; // Nr of matching non-term-code settings int count = 0; @@ -4748,7 +4748,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char *fuzzystr, int *numM int ic = regmatch->rm_ic; // remember the ignore-case flag fuzmatch_str_T *fuzmatch = NULL; - const bool fuzzy = cmdline_fuzzy_complete(fuzzystr); + const bool fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr); // do this loop twice: // loop == 0: count the number of matching options diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 11c2977a4e..f51de94bac 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -1238,6 +1238,30 @@ 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') + " Nvim doesn't have 'termencoding' + " call assert_equal('"set termguicolors termencoding', @:) + call assert_equal('"set termguicolors', @:) + + call feedkeys(":set notermg\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"set notermguicolors', @:) + + set wildoptions= +endfunc + func Test_switchbuf_reset() set switchbuf=useopen sblast |