0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.4755: cannot use <SID>FuncRef in completion spec

Problem:    Cannot use <SID>FuncRef in completion spec.
Solution:   Dereference a function name in another way. (closes #10197)
This commit is contained in:
Bram Moolenaar
2022-04-15 22:57:09 +01:00
parent 7714231bb5
commit 12eb2eb4d7
3 changed files with 35 additions and 1 deletions

View File

@@ -639,7 +639,15 @@ deref_function_name(
ref.v_type = VAR_UNKNOWN; ref.v_type = VAR_UNKNOWN;
if (eval7(arg, &ref, evalarg, FALSE) == FAIL) 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; return NULL;
copy_tv(&v->di_tv, &ref);
}
if (*skipwhite(*arg) != NUL) if (*skipwhite(*arg) != NUL)
{ {
if (verbose) if (verbose)

View File

@@ -749,6 +749,30 @@ def Test_use_import_in_command_completion()
delete('Xscript.vim') delete('Xscript.vim')
enddef 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() def Test_use_autoload_import_in_insert_completion()
mkdir('Xdir/autoload', 'p') mkdir('Xdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4755,
/**/ /**/
4754, 4754,
/**/ /**/