]> granicus.if.org Git - vim/commitdiff
patch 8.2.4755: cannot use <SID>FuncRef in completion spec v8.2.4755
authorBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2022 21:57:09 +0000 (22:57 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2022 21:57:09 +0000 (22:57 +0100)
Problem:    Cannot use <SID>FuncRef in completion spec.
Solution:   Dereference a function name in another way. (closes #10197)

src/eval.c
src/testdir/test_vim9_import.vim
src/version.c

index 90ed14b60856d85a800c4fca37f92d70833b0e4a..cad6887751c2d7ac619b538679db252f5d6a6072 100644 (file)
@@ -639,7 +639,15 @@ deref_function_name(
 
     ref.v_type = VAR_UNKNOWN;
     if (eval7(arg, &ref, evalarg, FALSE) == FAIL)
-       return NULL;
+    {
+       dictitem_T      *v;
+
+       // If <SID>VarName was used it would not be found, try another way.
+       v = find_var_also_in_script(name, NULL, FALSE);
+       if (v == NULL)
+           return NULL;
+       copy_tv(&v->di_tv, &ref);
+    }
     if (*skipwhite(*arg) != NUL)
     {
        if (verbose)
index dd9f5668db347e41766f2c70398c227358c49f92..ebd875ed9530611095dc1343d6d0faff47ed2495 100644 (file)
@@ -749,6 +749,30 @@ def Test_use_import_in_command_completion()
   delete('Xscript.vim')
 enddef
 
+def Test_use_import_with_funcref_in_command_completion()
+  var lines =<< trim END
+      vim9script
+      export def Complete(..._): list<string>
+        return ['abcd']
+      enddef
+  END
+  writefile(lines, 'Xscript.vim')
+
+  lines =<< trim END
+      vim9script
+      import './Xscript.vim'
+
+      var Ref = Xscript.Complete
+      exe "command -nargs=1 -complete=customlist," .. expand('<SID>') .. "Ref  Cmd echo 'ok'"
+      feedkeys(":Cmd ab\<Tab>\<C-B>#\<CR>", 'xnt')
+      assert_equal('#Cmd abcd', @:)
+  END
+  v9.CheckScriptSuccess(lines)
+
+  delcommand Cmd
+  delete('Xscript.vim')
+enddef
+
 def Test_use_autoload_import_in_insert_completion()
   mkdir('Xdir/autoload', 'p')
   var save_rtp = &rtp
index e833b78be716876af1f50e1354ebc5707dfa8f25..017557eb08b5fe4e577b099bde2ee4005d473860 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4755,
 /**/
     4754,
 /**/