diff options
Diffstat (limited to 'src/userfunc.c')
-rw-r--r-- | src/userfunc.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/src/userfunc.c b/src/userfunc.c index b495769a9..e2658fe59 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -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; - - // Find imported funcion before global one. - imported = find_imported(name, 0, cctx); - if (imported != NULL && imported->imp_funcname != NULL) + char_u *after_script = 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); + } } } |