patch 9.0.0744: in script in autoload dir exported variable is not found
Problem: In script in autoload dir exported variable is not found. (Doug
Kearns)
Solution: Find the variable with the "script#" prefix. (closes #11361)
diff --git a/src/evalvars.c b/src/evalvars.c
index fd443cd..132de4c 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1326,7 +1326,7 @@
}
return p + 1;
}
-
+
return skip_var_one(arg, include_type);
}
@@ -3160,18 +3160,20 @@
// 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)
{