Mercurial > vim
changeset 28166:130f4082a13d
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Commit: https://github.com/vim/vim/commit/e7dd0fa2c61fe71f12c72b0dcb7bb6415eb048fb
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Mar 22 16:06:31 2022 +0000
patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Problem: getcompletion() does not work properly when 'wildoptions
contains "fuzzy".
Solution: Do not use addstar(). (Yegappan Lakshmanan, closes #9992,
closes #9986)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Mar 2022 18:15:03 +0100 |
parents | da0e04fbb0a3 |
children | a52a5e3363c4 |
files | runtime/doc/builtin.txt src/cmdexpand.c src/testdir/test_cmdline.vim src/version.c |
diffstat | 4 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -3273,6 +3273,10 @@ getcompletion({pat}, {type} [, {filtered is applied to filter the results. Otherwise all the matches are returned. The 'wildignorecase' option always applies. + If the 'wildoptions' option contains 'fuzzy', then fuzzy + matching is used to get the completion matches. Otherwise + regular expression matching is used. + If {type} is "cmdline", then the |cmdline-completion| result is returned. For example, to complete the possible values after a ":call" command: >
--- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -3707,7 +3707,12 @@ f_getcompletion(typval_T *argvars, typva # endif } - pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); + if (cmdline_fuzzy_completion_supported(&xpc)) + // when fuzzy matching, don't modify the search string + pat = vim_strsave(xpc.xp_pattern); + else + pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); + if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL)) { int i;
--- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -552,6 +552,22 @@ func Test_getcompletion() call assert_fails('call getcompletion("abc", [])', 'E475:') endfunc +" Test for getcompletion() with "fuzzy" in 'wildoptions' +func Test_getcompletion_wildoptions() + let save_wildoptions = &wildoptions + set wildoptions& + let l = getcompletion('space', 'option') + call assert_equal([], l) + let l = getcompletion('ier', 'command') + call assert_equal([], l) + set wildoptions=fuzzy + let l = getcompletion('space', 'option') + call assert_true(index(l, 'backspace') >= 0) + let l = getcompletion('ier', 'command') + call assert_true(index(l, 'compiler') >= 0) + let &wildoptions = save_wildoptions +endfunc + func Test_complete_autoload_error() let save_rtp = &rtp let lines =<< trim END