Mercurial > vim
diff src/evalvars.c @ 27002:cf5b5e95f62b v8.2.4030
patch 8.2.4030: a script local funcref is not found from a mapping
Commit: https://github.com/vim/vim/commit/71f21938bc9f4f6c0e52c178f51cb19be9804690
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 7 18:20:55 2022 +0000
patch 8.2.4030: a script local funcref is not found from a mapping
Problem: A script local funcref is not found from a mapping.
Solution: When looking for a function, also find a script-local funcref.
(closes #9485)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 07 Jan 2022 19:30:03 +0100 |
parents | 4b8d836db103 |
children | 5d851ce07caf |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -2690,7 +2690,7 @@ eval_variable( { if ((flags & EVAL_VAR_IMPORT) == 0) { - if (sid != 0 && SCRIPT_ID_VALID(sid)) + if (SCRIPT_ID_VALID(sid)) { ht = &SCRIPT_VARS(sid); if (ht != NULL) @@ -2878,6 +2878,35 @@ find_var(char_u *name, hashtab_T **htp, } /* + * Like find_var() but if the name starts with <SNR>99_ then look in the + * referenced script (used for a funcref). + */ + dictitem_T * +find_var_also_in_script(char_u *name, hashtab_T **htp, int no_autoload) +{ + if (STRNCMP(name, "<SNR>", 5) == 0 && isdigit(name[5])) + { + char_u *p = name + 5; + int sid = getdigits(&p); + + if (SCRIPT_ID_VALID(sid) && *p == '_') + { + hashtab_T *ht = &SCRIPT_VARS(sid); + + if (ht != NULL) + { + dictitem_T *di = find_var_in_ht(ht, 0, p + 1, no_autoload); + + if (di != NULL) + return di; + } + } + } + + return find_var(name, htp, no_autoload); +} + +/* * Find variable "varname" in hashtab "ht" with name "htname". * When "varname" is empty returns curwin/curtab/etc vars dictionary. * Returns NULL if not found.