]> granicus.if.org Git - vim/commitdiff
patch 8.2.1398: autoload script sourced twice if sourced directly v8.2.1398
authorBram Moolenaar <Bram@vim.org>
Sat, 8 Aug 2020 19:33:21 +0000 (21:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 8 Aug 2020 19:33:21 +0000 (21:33 +0200)
Problem:    Autoload script sourced twice if sourced directly.
Solution:   Do not source an autoload script again. (issue #6644)

src/scriptfile.c
src/testdir/sautest/autoload/sourced.vim
src/version.c

index b93e3513807f076684bb77319f94751e0e264701..38215914d5aefdb3f6abb4a24ca8e78270f85d2c 100644 (file)
@@ -2012,6 +2012,7 @@ script_autoload(
     char_u     *scriptname, *tofree;
     int                ret = FALSE;
     int                i;
+    int                ret_sid;
 
     // If there is no '#' after name[0] there is no package name.
     p = vim_strchr(name, AUTOLOAD_CHAR);
@@ -2039,7 +2040,8 @@ script_autoload(
        }
 
        // Try loading the package from $VIMRUNTIME/autoload/<name>.vim
-       if (source_runtime(scriptname, 0) == OK)
+       // Use "ret_sid" to avoid loading the same script again.
+       if (source_in_path(p_rtp, scriptname, 0, &ret_sid) == OK)
            ret = TRUE;
     }
 
index f69f00cb5345afedc159c55b7de44b362c653b1a..aac96b11ce3b0a6d5fabc60edb7f23b699c19f8c 100644 (file)
@@ -1,3 +1,4 @@
 let g:loaded_sourced_vim += 1
-func! sourced#something()
+func sourced#something()
 endfunc
+call sourced#something()
index b67d3c3dac0003d4949336bd65eaad1d01b9e012..e97b3906e52b4684d751575f54fd29cff333c991 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1398,
 /**/
     1397,
 /**/