]> granicus.if.org Git - vim/commitdiff
patch 8.2.4135: Vim9: ":scriptnames" shows unloaded imported autoload script v8.2.4135
authorBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 14:16:59 +0000 (14:16 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 14:16:59 +0000 (14:16 +0000)
Problem:    Vim9: ":scriptnames" shows unloaded imported autoload script.
Solution:   Mark the unloaded script with "A". (closes #9552)

runtime/doc/repeat.txt
src/scriptfile.c
src/testdir/test_vim9_import.vim
src/version.c

index 8ea19584b56fcf4afc7ef76f0acefb5e058cbd05..067234a018d8b870b601178a2cb60ca1b6756cd9 100644 (file)
@@ -380,6 +380,9 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
 :scr[iptnames]         List all sourced script names, in the order they were
                        first sourced.  The number is used for the script ID
                        |<SID>|.
+                       For a script that was used with `import autoload` but
+                       was not actually sourced yet an "A" is shown after the
+                       script ID.
                        {not available when compiled without the |+eval|
                        feature}
 
index 159c9fc675ed208c89f8b9fd77cd1369f8b4c848..5b1e43b78f490e446514da1f99da5e714041bee8 100644 (file)
@@ -1648,16 +1648,22 @@ ex_scriptnames(exarg_T *eap)
     }
 
     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)
index 79c1ca43e28ef20f7c3dcfdb1c8d40cfd00c748f..6abe478701fd7c25d94aa14afacbeea81d7eba43 100644 (file)
@@ -1397,10 +1397,12 @@ def Test_autoload_mapping()
   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)
index 8ac5c086708d22f396abf9ca5d1045e1e78a7551..679d25889b4b06890268bc89c4edcdef204c826d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4135,
 /**/
     4134,
 /**/