summaryrefslogtreecommitdiffstats
path: root/src/vim9script.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:10:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:10:59 +0000
commitcccb21df3b4c6fe0aaa99743c418aa973aeebad0 (patch)
tree35a2d1f88d47e930fec425da1c1cb89b3ccae6e0 /src/vim9script.c
parentReleasing progress-linux version 2:9.1.0199-1~progress7.99u1. (diff)
downloadvim-cccb21df3b4c6fe0aaa99743c418aa973aeebad0.tar.xz
vim-cccb21df3b4c6fe0aaa99743c418aa973aeebad0.zip
Merging upstream version 2:9.1.0374.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/vim9script.c')
-rw-r--r--src/vim9script.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/vim9script.c b/src/vim9script.c
index a64ce72..3035889 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -456,15 +456,24 @@ handle_import(
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
char_u *tail = gettail(si->sn_name);
char_u *from_name;
+ int sourced_from_nofile_buf = FALSE;
- // Relative to current script: "./name.vim", "../../name.vim".
- len = STRLEN(si->sn_name) - STRLEN(tail) + STRLEN(tv.vval.v_string) + 2;
- from_name = alloc((int)len);
- if (from_name == NULL)
- goto erret;
- vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
- add_pathsep(from_name);
- STRCAT(from_name, tv.vval.v_string);
+ if (STRNCMP(si->sn_name, ":source buffer=", 15) == 0)
+ sourced_from_nofile_buf = TRUE;
+
+ if (!sourced_from_nofile_buf)
+ {
+ // Relative to current script: "./name.vim", "../../name.vim".
+ len = STRLEN(si->sn_name) - STRLEN(tail) + STRLEN(tv.vval.v_string) + 2;
+ from_name = alloc((int)len);
+ if (from_name == NULL)
+ goto erret;
+ vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
+ add_pathsep(from_name);
+ STRCAT(from_name, tv.vval.v_string);
+ }
+ else
+ from_name = vim_strsave(tv.vval.v_string);
simplify_filename(from_name);
res = handle_import_fname(from_name, is_autoload, &sid);