diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-13 17:47:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-13 17:47:42 +0100 |
commit | 6c4d4a64449ea225b1a568f5517e309b2054b490 (patch) | |
tree | feb56a6031ecd131f8dd25e7a318ef89f701cc51 /src/evalvars.c | |
parent | 66b8d2a89efb6bd482e3160c7494e646e31aea27 (diff) |
patch 9.0.0744: in script in autoload dir exported variable is not foundv9.0.0744
Problem: In script in autoload dir exported variable is not found. (Doug
Kearns)
Solution: Find the variable with the "script#" prefix. (closes #11361)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index fd443cd40f..132de4c717 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1326,7 +1326,7 @@ skip_var_list( } return p + 1; } - + return skip_var_one(arg, include_type); } @@ -3160,18 +3160,20 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload) // When using "vim9script autoload" script-local items are prefixed but can // be used with s:name. if (SCRIPT_ID_VALID(current_sctx.sc_sid) - && name[0] == 's' && name[1] == ':') + && (in_vim9script() || (name[0] == 's' && name[1] == ':'))) { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_autoload_prefix != NULL) { - char_u *auto_name = concat_str(si->sn_autoload_prefix, name + 2); + char_u *base_name = (name[0] == 's' && name[1] == ':') + ? name + 2 : name; + char_u *auto_name = concat_str(si->sn_autoload_prefix, base_name); if (auto_name != NULL) { ht = &globvarht; - ret = find_var_in_ht(ht, *name, auto_name, TRUE); + ret = find_var_in_ht(ht, 'g', auto_name, TRUE); vim_free(auto_name); if (ret != NULL) { |