patch 8.2.4135: Vim9: ":scriptnames" shows unloaded imported autoload script
Problem: Vim9: ":scriptnames" shows unloaded imported autoload script.
Solution: Mark the unloaded script with "A". (closes #9552)
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 159c9fc..5b1e43b 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1648,16 +1648,22 @@
}
for (i = 1; i <= script_items.ga_len && !got_int; ++i)
- if (SCRIPT_ITEM(i)->sn_name != NULL)
+ {
+ scriptitem_T *si = SCRIPT_ITEM(i);
+
+ if (si->sn_name != NULL)
{
- home_replace(NULL, SCRIPT_ITEM(i)->sn_name,
- NameBuff, MAXPATHL, TRUE);
- vim_snprintf((char *)IObuff, IOSIZE, "%3d: %s", i, NameBuff);
+ home_replace(NULL, si->sn_name, NameBuff, MAXPATHL, TRUE);
+ vim_snprintf((char *)IObuff, IOSIZE, "%3d%s: %s",
+ i,
+ si->sn_state == SN_STATE_NOT_LOADED ? " A" : "",
+ NameBuff);
msg_putchar('\n');
msg_outtrans(IObuff);
out_flush(); // output one line at a time
ui_breakcheck();
}
+ }
}
# if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index 79c1ca4..6abe478 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1397,10 +1397,12 @@
CheckScriptSuccess(lines)
assert_false(exists("g:toggle_loaded"))
assert_false(exists("g:toggle_called"))
+ assert_match('\d A: \f*[/\\]toggle.vim', execute('scriptnames'))
feedkeys("tt", 'xt')
assert_equal('yes', g:toggle_loaded)
assert_equal('yes', g:toggle_called)
+ assert_match('\d: \f*[/\\]toggle.vim', execute('scriptnames'))
feedkeys("xx", 'xt')
assert_equal('yes', g:doit_called)
diff --git a/src/version.c b/src/version.c
index 8ac5c08..679d258 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4135,
+/**/
4134,
/**/
4133,