vim-patch:8.2.1398: autoload script sourced twice if sourced directly (#22622)

Problem:    Autoload script sourced twice if sourced directly.
Solution:   Do not source an autoload script again. (issue vim/vim#6644)

daa2f36573

Cherry-pick ret_sid changes from patch 8.2.0149.
Use do_in_runtimepath() as that's what source_runtime() calls in Nvim.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-03-11 21:29:25 +08:00
committed by GitHub
parent 6d0c61d90d
commit 7dc9182cf0
7 changed files with 59 additions and 49 deletions

View File

@@ -1937,7 +1937,7 @@ static void do_system_initialization(void)
dir_len += 1;
}
memcpy(vimrc + dir_len, path_tail, sizeof(path_tail));
if (do_source(vimrc, false, DOSO_NONE) != FAIL) {
if (do_source(vimrc, false, DOSO_NONE, NULL) != FAIL) {
xfree(vimrc);
xfree(config_dirs);
return;
@@ -1949,7 +1949,7 @@ static void do_system_initialization(void)
#ifdef SYS_VIMRC_FILE
// Get system wide defaults, if the file name is defined.
(void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE);
(void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL);
#endif
}
@@ -1978,7 +1978,7 @@ static bool do_user_initialization(void)
// init.lua
if (os_path_exists(init_lua_path)
&& do_source(init_lua_path, true, DOSO_VIMRC)) {
&& do_source(init_lua_path, true, DOSO_VIMRC, NULL)) {
if (os_path_exists(user_vimrc)) {
semsg(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path,
user_vimrc);
@@ -1992,7 +1992,7 @@ static bool do_user_initialization(void)
xfree(init_lua_path);
// init.vim
if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
if (do_source(user_vimrc, true, DOSO_VIMRC, NULL) != FAIL) {
do_exrc = p_exrc;
if (do_exrc) {
do_exrc = (path_full_compare(VIMRC_FILE, user_vimrc, false, true) != kEqualFiles);
@@ -2018,7 +2018,7 @@ static bool do_user_initialization(void)
memmove(vimrc, dir, dir_len);
vimrc[dir_len] = PATHSEP;
memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
if (do_source(vimrc, true, DOSO_VIMRC) != FAIL) {
if (do_source(vimrc, true, DOSO_VIMRC, NULL) != FAIL) {
do_exrc = p_exrc;
if (do_exrc) {
do_exrc = (path_full_compare(VIMRC_FILE, vimrc, false, true) != kEqualFiles);
@@ -2084,7 +2084,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|| strequal(parmp->use_vimrc, "NORC")) {
// Do nothing.
} else {
if (do_source(parmp->use_vimrc, false, DOSO_NONE) != OK) {
if (do_source(parmp->use_vimrc, false, DOSO_NONE, NULL) != OK) {
semsg(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
}
}