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/vim9script.c b/src/vim9script.c
index 6f84362..913e66c 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -697,6 +697,20 @@
}
/*
+ * When a script is a symlink it may be imported with one name and sourced
+ * under another name. Adjust the import script ID if needed.
+ * "*sid" must be a valid script ID.
+ */
+ void
+import_check_sourced_sid(int *sid)
+{
+ scriptitem_T *script = SCRIPT_ITEM(*sid);
+
+ if (script->sn_sourced_sid > 0)
+ *sid = script->sn_sourced_sid;
+}
+
+/*
* Find an exported item in "sid" matching "name".
* Either "cctx" or "cstack" is NULL.
* When it is a variable return the index.