]> granicus.if.org Git - vim/commitdiff
patch 8.2.3550: completion() does not work properly v8.2.3550
authorShougo Matsushita <Shougo.Matsu@gmail.com>
Thu, 21 Oct 2021 10:39:53 +0000 (11:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 21 Oct 2021 10:39:53 +0000 (11:39 +0100)
Problem:    completion() does not work properly.
Solution:   Set xp_line and add WILD_HOME_REPLACE. (Shougo Matsushita,
            closes #9016)

src/cmdexpand.c
src/testdir/test_cmdline.vim
src/version.c

index c98e126a5c2b0fbe389ea6d000c978812b6dd2d2..71c4f690cb842633172e9f8c3b6b4d0fa610da30 100644 (file)
@@ -978,6 +978,7 @@ set_one_cmd_context(
 
     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 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
     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
index 9c21a205f78fbd291a81eedacb5b6de97d44a23e..87ae6faa2f45efa2b7ed6e04f45d260db2606d48 100644 (file)
@@ -305,6 +305,11 @@ func Test_getcompletion()
   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 @@ func Test_getcompletion()
   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')
index 5df626a970430e1bd45cecf5772a94f2e3e74d37..e4f72bd6720d431a4729c1b91a765cb0bd9241dc 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3550,
 /**/
     3549,
 /**/