Patch 8.2.4755
Problem:    Cannot use <SID>FuncRef in completion spec.
Solution:   Dereference a function name in another way. (closes #10197)
Files:      src/eval.c, src/testdir/test_vim9_import.vim


*** ../vim-8.2.4754/src/eval.c  2022-04-15 13:53:30.044708701 +0100
--- src/eval.c  2022-04-15 22:42:49.075947104 +0100
***************
*** 639,645 ****
  
      ref.v_type = VAR_UNKNOWN;
      if (eval7(arg, &ref, evalarg, FALSE) == FAIL)
!       return NULL;
      if (*skipwhite(*arg) != NUL)
      {
        if (verbose)
--- 639,653 ----
  
      ref.v_type = VAR_UNKNOWN;
      if (eval7(arg, &ref, evalarg, FALSE) == FAIL)
!     {
!       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)
*** ../vim-8.2.4754/src/testdir/test_vim9_import.vim    2022-04-14 
21:36:09.551209661 +0100
--- src/testdir/test_vim9_import.vim    2022-04-15 22:42:03.239917510 +0100
***************
*** 749,754 ****
--- 749,778 ----
    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
*** ../vim-8.2.4754/src/version.c       2022-04-15 20:50:13.463235819 +0100
--- src/version.c       2022-04-15 22:32:24.913037782 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4755,
  /**/

-- 
Normal people believe that if it ain't broke, don't fix it.  Engineers believe
that if it ain't broke, it doesn't have enough features yet.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220415215741.1F0CC1C05DA%40moolenaar.net.

Raspunde prin e-mail lui