diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_import.vim | 36 | ||||
-rw-r--r-- | src/testing.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9script.c | 3 |
5 files changed, 44 insertions, 0 deletions
diff --git a/src/globals.h b/src/globals.h index f04b29e8b..94da8e0c5 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1643,6 +1643,7 @@ EXTERN int no_query_mouse_for_testing INIT(= FALSE); EXTERN int ui_delay_for_testing INIT(= 0); EXTERN int reset_term_props_on_termresponse INIT(= FALSE); EXTERN long override_sysinfo_uptime INIT(= -1); +EXTERN int override_autoload INIT(= FALSE); EXTERN int in_free_unref_items INIT(= FALSE); #endif diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 553ef8fdc..2e57fe252 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -1288,6 +1288,42 @@ def Test_import_autoload_postponed() &rtp = save_rtp enddef +def Test_import_autoload_override() + mkdir('Xdir/autoload', 'p') + var save_rtp = &rtp + exe 'set rtp^=' .. getcwd() .. '/Xdir' + test_override('autoload', 1) + + var lines =<< trim END + vim9script autoload + + g:loaded_override = 'true' + export var variable = 'bla' + export def Function(): string + return 'bla' + enddef + END + writefile(lines, 'Xdir/autoload/override.vim') + + lines =<< trim END + vim9script + + import autoload 'override.vim' + assert_equal('true', g:loaded_override) + + def Tryit() + echo override.doesNotExist + enddef + defcompile + END + CheckScriptFailure(lines, 'E1048: Item not found in script: doesNotExist', 1) + + test_override('autoload', 0) + unlet g:loaded_override + delete('Xdir', 'rf') + &rtp = save_rtp +enddef + def Test_autoload_mapping() mkdir('Xdir/autoload', 'p') var save_rtp = &rtp diff --git a/src/testing.c b/src/testing.c index eef5e0d76..34826826f 100644 --- a/src/testing.c +++ b/src/testing.c @@ -1055,6 +1055,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED) reset_term_props_on_termresponse = val; else if (STRCMP(name, (char_u *)"uptime") == 0) override_sysinfo_uptime = val; + else if (STRCMP(name, (char_u *)"autoload") == 0) + override_autoload = val; else if (STRCMP(name, (char_u *)"ALL") == 0) { disable_char_avail_for_testing = FALSE; diff --git a/src/version.c b/src/version.c index 728d2b8a7..782a64a11 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4087, +/**/ 4086, /**/ 4085, diff --git a/src/vim9script.c b/src/vim9script.c index baf2019f5..2038c78a0 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -496,6 +496,9 @@ handle_import( if (si->sn_autoload_prefix == NULL) si->sn_autoload_prefix = get_autoload_prefix(si); res = OK; + if (override_autoload && si->sn_state == SN_STATE_NOT_LOADED) + // testing override: load autoload script right away + (void)do_source(si->sn_name, FALSE, DOSO_NONE, NULL); } else res = FAIL; |