comparison src/scriptfile.c @ 21697:6c477989f9a4 v8.2.1398

patch 8.2.1398: autoload script sourced twice if sourced directly Commit: https://github.com/vim/vim/commit/daa2f36573db3e1df7eb1fdbc3a09a2815644048 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 8 21:33:21 2020 +0200 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 https://github.com/vim/vim/issues/6644)
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Aug 2020 21:45:04 +0200
parents 766839794e09
children 9ef7ae8ab51c
comparison
equal deleted inserted replaced
21696:217fe247a68b 21697:6c477989f9a4
2010 { 2010 {
2011 char_u *p; 2011 char_u *p;
2012 char_u *scriptname, *tofree; 2012 char_u *scriptname, *tofree;
2013 int ret = FALSE; 2013 int ret = FALSE;
2014 int i; 2014 int i;
2015 int ret_sid;
2015 2016
2016 // If there is no '#' after name[0] there is no package name. 2017 // If there is no '#' after name[0] there is no package name.
2017 p = vim_strchr(name, AUTOLOAD_CHAR); 2018 p = vim_strchr(name, AUTOLOAD_CHAR);
2018 if (p == NULL || p == name) 2019 if (p == NULL || p == name)
2019 return FALSE; 2020 return FALSE;
2037 ((char_u **)ga_loaded.ga_data)[ga_loaded.ga_len++] = scriptname; 2038 ((char_u **)ga_loaded.ga_data)[ga_loaded.ga_len++] = scriptname;
2038 tofree = NULL; 2039 tofree = NULL;
2039 } 2040 }
2040 2041
2041 // Try loading the package from $VIMRUNTIME/autoload/<name>.vim 2042 // 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)
2043 ret = TRUE; 2045 ret = TRUE;
2044 } 2046 }
2045 2047
2046 vim_free(tofree); 2048 vim_free(tofree);
2047 return ret; 2049 return ret;