Skip to content

Commit daa2f36

Browse files
committed
patch 8.2.1398: autoload script sourced twice if sourced directly
Problem: Autoload script sourced twice if sourced directly. Solution: Do not source an autoload script again. (issue #6644)
1 parent 4a6d1b6 commit daa2f36

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/scriptfile.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ script_autoload(
20122012
char_u *scriptname, *tofree;
20132013
int ret = FALSE;
20142014
int i;
2015+
int ret_sid;
20152016

20162017
// If there is no '#' after name[0] there is no package name.
20172018
p = vim_strchr(name, AUTOLOAD_CHAR);
@@ -2039,7 +2040,8 @@ script_autoload(
20392040
}
20402041

20412042
// Try loading the package from $VIMRUNTIME/autoload/<name>.vim
2042-
if (source_runtime(scriptname, 0) == OK)
2043+
// Use "ret_sid" to avoid loading the same script again.
2044+
if (source_in_path(p_rtp, scriptname, 0, &ret_sid) == OK)
20432045
ret = TRUE;
20442046
}
20452047

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
let g:loaded_sourced_vim += 1
2-
func! sourced#something()
2+
func sourced#something()
33
endfunc
4+
call sourced#something()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1398,
757759
/**/
758760
1397,
759761
/**/

0 commit comments

Comments
 (0)