aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-26 07:40:21 +0800
committerGitHub <noreply@github.com>2025-02-25 23:40:21 +0000
commite2aca58bcc4f0aff8da9683194e4dc857a56118f (patch)
treed077b324c29de6d53ca42f9496efb9451fc40b05 /src/nvim/eval.c
parentaf0a2157ad2958b6c1e3c374ac247726c252c219 (diff)
downloadrneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.gz
rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.bz2
rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.zip
fix(lua): don't override script ID from :source (#32626)
Problem: When setting an option, mapping etc. from Lua without -V1, the script ID is set to SID_LUA even if there already is a script ID assigned by :source. Solution: Don't set script ID to SID_LUA if it is already a Lua script. Also add _editor.lua to ignorelist to make script context more useful when using vim.cmd().
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 18f83bfb6b..bd15b7110f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7646,22 +7646,8 @@ hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, const char
|| current_sctx.sc_sid == SID_LUA)
&& current_sctx.sc_sid <= script_items.ga_len) {
// For anonymous scripts without a script item, create one now so script vars can be used
- if (current_sctx.sc_sid == SID_LUA) {
- // try to resolve lua filename & line no so it can be shown in lastset messages.
- nlua_set_sctx(&current_sctx);
- if (current_sctx.sc_sid != SID_LUA) {
- // Great we have valid location. Now here this out we'll create a new
- // script context with the name and lineno of this one. why ?
- // for behavioral consistency. With this different anonymous exec from
- // same file can't access each others script local stuff. We need to do
- // this all other cases except this will act like that otherwise.
- bool should_free;
- // should_free is ignored as script_ctx will be resolved to a fname
- // and new_script_item() will consume it.
- char *sc_name = get_scriptname(current_sctx, &should_free);
- new_script_item(sc_name, &current_sctx.sc_sid);
- }
- }
+ // Try to resolve lua filename & linenr so it can be shown in last-set messages.
+ nlua_set_sctx(&current_sctx);
if (current_sctx.sc_sid == SID_STR || current_sctx.sc_sid == SID_LUA) {
// Create SID if s: scope is accessed from Lua or anon Vimscript. #15994
new_script_item(NULL, &current_sctx.sc_sid);