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)
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index c98e126..71c4f69 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -978,6 +978,7 @@
ExpandInit(xp);
xp->xp_pattern = buff;
+ xp->xp_line = buff;
xp->xp_context = EXPAND_COMMANDS; // Default until we get past command
ea.argt = 0;
@@ -2891,7 +2892,7 @@
expand_T xpc;
int filtered = FALSE;
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
- | WILD_NO_BEEP;
+ | WILD_NO_BEEP | WILD_HOME_REPLACE;
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 9c21a20..87ae6fa 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -305,6 +305,11 @@
let l = getcompletion('NoMatch', 'dir')
call assert_equal([], l)
+ if glob('~/*') !=# ''
+ let l = getcompletion('~/', 'dir')
+ call assert_true(l[0][0] ==# '~')
+ endif
+
let l = getcompletion('exe', 'expression')
call assert_true(index(l, 'executable(') >= 0)
let l = getcompletion('kill', 'expression')
@@ -418,6 +423,16 @@
let l = getcompletion('call paint', 'cmdline')
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.
let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user']
if has('cmdline_hist')
diff --git a/src/version.c b/src/version.c
index 5df626a..e4f72bd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3550,
+/**/
3549,
/**/
3548,