summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-22 11:27:29 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-22 11:27:29 +0000
commitb697dc295d0625bf2445649f03019f9b8fccc1a8 (patch)
tree5dccc253b9b1b5e7a6469c74f63ca3682b29c6d4 /src
parent3d8e25a6d2660432df033cdad29f981ffe6ae0fc (diff)
downloadvim-git-b697dc295d0625bf2445649f03019f9b8fccc1a8.tar.gz
patch 8.2.4177: Vim9: autoload script not loaded after "vim9script noclear"v8.2.4177
Problem: Vim9: autoload script not loaded after "vim9script noclear". Solution: Check IMP_FLAGS_AUTOLOAD properly.
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_import.vim42
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c4
3 files changed, 46 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index f06bea2c8..df22a7719 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1535,6 +1535,48 @@ def Test_vim9script_autoload_call()
&rtp = save_rtp
enddef
+def Test_vim9script_noclear_autoload()
+ mkdir('Xdir/autoload', 'p')
+ var save_rtp = &rtp
+ exe 'set rtp^=' .. getcwd() .. '/Xdir'
+
+ var lines =<< trim END
+ vim9script
+ export def Func(): string
+ return 'called'
+ enddef
+ g:double_loaded = 'yes'
+ END
+ writefile(lines, 'Xdir/autoload/double.vim')
+
+ lines =<< trim END
+ vim9script noclear
+ if exists('g:script_loaded')
+ finish
+ endif
+ g:script_loaded = true
+
+ import autoload 'double.vim'
+ nnoremap <F3> <ScriptCmd>g:result = double.Func()<CR>
+ END
+ g:double_loaded = 'no'
+ writefile(lines, 'Xloaddouble')
+ source Xloaddouble
+ assert_equal('no', g:double_loaded)
+ assert_equal(true, g:script_loaded)
+ source Xloaddouble
+ feedkeys("\<F3>", 'xt')
+ assert_equal('called', g:result)
+ assert_equal('yes', g:double_loaded)
+
+ delete('Xloaddouble')
+ unlet g:double_loaded
+ unlet g:script_loaded
+ unlet g:result
+ delete('Xdir', 'rf')
+ &rtp = save_rtp
+enddef
+
def Test_vim9script_autoload_duplicate()
mkdir('Xdir/autoload', 'p')
diff --git a/src/version.c b/src/version.c
index 7f0dff578..154b7e314 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 */
/**/
+ 4177,
+/**/
4176,
/**/
4175,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index ddb486b01..2b706ad18 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -621,12 +621,12 @@ find_imported(char_u *name, size_t len, int load, cctx_T *cctx)
if (ret == NULL)
ret = find_imported_in_script(name, len, current_sctx.sc_sid);
- if (ret != NULL && load && ret->imp_flags == IMP_FLAGS_AUTOLOAD)
+ if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD))
{
scid_T dummy;
// script found before but not loaded yet
- ret->imp_flags = 0;
+ ret->imp_flags &= ~IMP_FLAGS_AUTOLOAD;
(void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE,
DOSO_NONE, &dummy);
}