0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.3550: completion() does not work properly

Problem:    completion() does not work properly.
Solution:   Set xp_line and add WILD_HOME_REPLACE. (Shougo Matsushita,
            closes #9016)
This commit is contained in:
Shougo Matsushita
2021-10-21 11:39:53 +01:00
committed by Bram Moolenaar
parent b811de5d49
commit ae38a9db77
3 changed files with 19 additions and 1 deletions

View File

@@ -978,6 +978,7 @@ set_one_cmd_context(
ExpandInit(xp); ExpandInit(xp);
xp->xp_pattern = buff; xp->xp_pattern = buff;
xp->xp_line = buff;
xp->xp_context = EXPAND_COMMANDS; // Default until we get past command xp->xp_context = EXPAND_COMMANDS; // Default until we get past command
ea.argt = 0; ea.argt = 0;
@@ -2891,7 +2892,7 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
expand_T xpc; expand_T xpc;
int filtered = FALSE; int filtered = FALSE;
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
| WILD_NO_BEEP; | WILD_NO_BEEP | WILD_HOME_REPLACE;
if (in_vim9script() if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL && (check_for_string_arg(argvars, 0) == FAIL

View File

@@ -305,6 +305,11 @@ func Test_getcompletion()
let l = getcompletion('NoMatch', 'dir') let l = getcompletion('NoMatch', 'dir')
call assert_equal([], l) call assert_equal([], l)
if glob('~/*') !=# ''
let l = getcompletion('~/', 'dir')
call assert_true(l[0][0] ==# '~')
endif
let l = getcompletion('exe', 'expression') let l = getcompletion('exe', 'expression')
call assert_true(index(l, 'executable(') >= 0) call assert_true(index(l, 'executable(') >= 0)
let l = getcompletion('kill', 'expression') let l = getcompletion('kill', 'expression')
@@ -418,6 +423,16 @@ func Test_getcompletion()
let l = getcompletion('call paint', 'cmdline') let l = getcompletion('call paint', 'cmdline')
call assert_equal([], l) call assert_equal([], l)
func T(a, c, p)
return "oneA\noneB\noneC"
endfunc
command -nargs=1 -complete=custom,T MyCmd
let l = getcompletion('MyCmd ', 'cmdline')
call assert_equal(['oneA', 'oneB', 'oneC'], l)
delcommand MyCmd
delfunc T
" For others test if the name is recognized. " For others test if the name is recognized.
let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user'] let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user']
if has('cmdline_hist') if has('cmdline_hist')

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3550,
/**/ /**/
3549, 3549,
/**/ /**/