summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-13 20:18:56 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-13 20:18:56 +0000
commit0e3e7ba05fa9cebe17d38def97ecd38a987d02ec (patch)
tree5b3a0ce1b336eb9052b612e75e1bfd14a47ef86a /src/evalvars.c
parent3049fcf0a189b0fea8468fa308887b8252d93dce (diff)
downloadvim-git-0e3e7ba05fa9cebe17d38def97ecd38a987d02ec.tar.gz
patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variablev8.2.4083
Problem: Vim9: no test for "vim9script autoload' and using script variable in the same script. Solution: Add a simple test. Fix uncovered problem.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 9bd1cc14c..92dcd7697 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2874,6 +2874,32 @@ 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] == ':')
+ {
+ 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);
+
+ if (auto_name != NULL)
+ {
+ ht = &globvarht;
+ ret = find_var_in_ht(ht, *name, auto_name, TRUE);
+ if (ret != NULL)
+ {
+ if (htp != NULL)
+ *htp = ht;
+ return ret;
+ }
+ }
+ vim_free(auto_name);
+ }
+ }
+
return NULL;
}
@@ -3318,7 +3344,7 @@ set_var(
}
/*
- * Set variable "name" to value in "tv".
+ * Set variable "name" to value in "tv_arg".
* When "sid" is non-zero "name" is in the script with this ID.
* If the variable already exists and "is_const" is FALSE the value is updated.
* Otherwise the variable is created.