patch 9.0.0253: a symlink to an autoload script results in two entries
Problem: A symlink to an autoload script results in two entries in the list
of scripts, items expected in one are actually in the other.
Solution: Have one script item refer to the actually sourced one.
(closes #10960)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index d8596e9..bf7390b 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -610,7 +610,7 @@
ret = find_imported_in_script(name, len, current_sctx.sc_sid);
if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD))
{
- scid_T dummy;
+ scid_T actual_sid = 0;
int save_emsg_off = emsg_off;
// "emsg_off" will be set when evaluating an expression silently, but
@@ -621,7 +621,11 @@
// script found before but not loaded yet
ret->imp_flags &= ~IMP_FLAGS_AUTOLOAD;
(void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE,
- DOSO_NONE, &dummy);
+ DOSO_NONE, &actual_sid);
+ // If the script is a symlink it may be sourced with another name, may
+ // need to adjust the script ID for that.
+ if (actual_sid != 0)
+ ret->imp_sid = actual_sid;
emsg_off = save_emsg_off;
}