diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-30 21:12:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-30 21:12:27 +0100 |
commit | c0ceeeb839b8c6bebd3a2abd1c07d40ec3c6edca (patch) | |
tree | 2f51e084f45dbe3437520d32f83e67fb9704aa6b /src/scriptfile.c | |
parent | b4ad3b0deac12674a7773311890b48fd39c6807c (diff) | |
download | vim-git-c0ceeeb839b8c6bebd3a2abd1c07d40ec3c6edca.tar.gz |
patch 8.2.4650: "import autoload" only works with using 'runtimepath'v8.2.4650
Problem: "import autoload" only works with using 'runtimepath'.
Solution: Also support a relative and absolute file name.
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r-- | src/scriptfile.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c index 39936a426..ec47edf72 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -251,7 +251,7 @@ source_callback(char_u *fname, void *cookie) * Find an already loaded script "name". * If found returns its script ID. If not found returns -1. */ - static int + int find_script_by_name(char_u *name) { int sid; @@ -320,6 +320,21 @@ get_new_scriptitem(int *error) return sid; } + int +get_new_scriptitem_for_fname(int *error, char_u *fname) +{ + int sid = get_new_scriptitem(error); + + if (*error == OK) + { + scriptitem_T *si = SCRIPT_ITEM(sid); + + si->sn_name = vim_strsave(fname); + si->sn_state = SN_STATE_NOT_LOADED; + } + return sid; +} + static void find_script_callback(char_u *fname, void *cookie) { @@ -329,17 +344,8 @@ find_script_callback(char_u *fname, void *cookie) sid = find_script_by_name(fname); if (sid < 0) - { // script does not exist yet, create a new scriptitem - sid = get_new_scriptitem(&error); - if (error == OK) - { - scriptitem_T *si = SCRIPT_ITEM(sid); - - si->sn_name = vim_strsave(fname); - si->sn_state = SN_STATE_NOT_LOADED; - } - } + sid = get_new_scriptitem_for_fname(&error, fname); *ret_sid = sid; } #endif |