forked from aniani/vim
patch 8.2.0960: cannot use :import in legacy Vim script
Problem: Cannot use :import in legacy Vim script. Solution: Support :import in any Vim script.
This commit is contained in:
@@ -719,20 +719,45 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
|
||||
ufunc_T *func;
|
||||
imported_T *imported;
|
||||
|
||||
if (in_vim9script() && !is_global)
|
||||
if (!is_global)
|
||||
{
|
||||
// Find script-local function before global one.
|
||||
func = find_func_with_sid(name, current_sctx.sc_sid);
|
||||
if (func != NULL)
|
||||
return func;
|
||||
char_u *after_script = NULL;
|
||||
|
||||
// Find imported funcion before global one.
|
||||
imported = find_imported(name, 0, cctx);
|
||||
if (imported != NULL && imported->imp_funcname != NULL)
|
||||
if (in_vim9script())
|
||||
{
|
||||
hi = hash_find(&func_hashtab, imported->imp_funcname);
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
return HI2UF(hi);
|
||||
// Find script-local function before global one.
|
||||
func = find_func_with_sid(name, current_sctx.sc_sid);
|
||||
if (func != NULL)
|
||||
return func;
|
||||
}
|
||||
|
||||
if (!in_vim9script()
|
||||
&& name[0] == K_SPECIAL
|
||||
&& name[1] == KS_EXTRA
|
||||
&& name[2] == KE_SNR)
|
||||
{
|
||||
long sid;
|
||||
|
||||
// Caller changes s: to <SNR>99_name.
|
||||
|
||||
after_script = name + 3;
|
||||
sid = getdigits(&after_script);
|
||||
if (sid == current_sctx.sc_sid && *after_script == '_')
|
||||
++after_script;
|
||||
else
|
||||
after_script = NULL;
|
||||
}
|
||||
if (in_vim9script() || after_script != NULL)
|
||||
{
|
||||
// Find imported function before global one.
|
||||
imported = find_imported(
|
||||
after_script == NULL ? name : after_script, 0, cctx);
|
||||
if (imported != NULL && imported->imp_funcname != NULL)
|
||||
{
|
||||
hi = hash_find(&func_hashtab, imported->imp_funcname);
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
return HI2UF(hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user