# HG changeset patch # User Bram Moolenaar # Date 1650060003 -7200 # Node ID 938c174b808898e0934b6b00c8d28bab94238ac2 # Parent 5bd8735b98a46d8600971f39c76124dcbc68f289 patch 8.2.4755: cannot use FuncRef in completion spec Commit: https://github.com/vim/vim/commit/12eb2eb4d78828513d91e04b0e69550ed37a5932 Author: Bram Moolenaar Date: Fri Apr 15 22:57:09 2022 +0100 patch 8.2.4755: cannot use FuncRef in completion spec Problem: Cannot use FuncRef in completion spec. Solution: Dereference a function name in another way. (closes https://github.com/vim/vim/issues/10197) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -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 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) diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -749,6 +749,30 @@ def Test_use_import_in_command_completio delete('Xscript.vim') enddef +def Test_use_import_with_funcref_in_command_completion() + var lines =<< trim END + vim9script + export def Complete(..._): list + 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('') .. "Ref Cmd echo 'ok'" + feedkeys(":Cmd ab\\#\", '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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4755, +/**/ 4754, /**/ 4753,