Patch 8.2.4177
Problem:    Vim9: autoload script not loaded after "vim9script noclear".
Solution:   Check IMP_FLAGS_AUTOLOAD properly.
Files:      src/vim9compile.c, src/testdir/test_vim9_import.vim


*** ../vim-8.2.4176/src/vim9compile.c   2022-01-19 20:48:33.496661246 +0000
--- src/vim9compile.c   2022-01-22 11:17:58.324755218 +0000
***************
*** 621,632 ****
      if (ret == NULL)
        ret = find_imported_in_script(name, len, current_sctx.sc_sid);
  
!     if (ret != NULL && load && ret->imp_flags == IMP_FLAGS_AUTOLOAD)
      {
        scid_T dummy;
  
        // script found before but not loaded yet
!       ret->imp_flags = 0;
        (void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE,
                                                            DOSO_NONE, &dummy);
      }
--- 621,632 ----
      if (ret == NULL)
        ret = find_imported_in_script(name, len, current_sctx.sc_sid);
  
!     if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD))
      {
        scid_T dummy;
  
        // script found before but not loaded yet
!       ret->imp_flags &= ~IMP_FLAGS_AUTOLOAD;
        (void)do_source(SCRIPT_ITEM(ret->imp_sid)->sn_name, FALSE,
                                                            DOSO_NONE, &dummy);
      }
*** ../vim-8.2.4176/src/testdir/test_vim9_import.vim    2022-01-22 
10:59:58.443950062 +0000
--- src/testdir/test_vim9_import.vim    2022-01-22 11:26:21.415233222 +0000
***************
*** 1535,1540 ****
--- 1535,1582 ----
    &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')
  
*** ../vim-8.2.4176/src/version.c       2022-01-22 10:59:58.447949998 +0000
--- src/version.c       2022-01-22 11:19:26.043105152 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4177,
  /**/

-- 
An indication you must be a manager:
You believe you never have any problems in your life, just
"issues" and "improvement opportunities".

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220122112809.333541C11B3%40moolenaar.net.

Raspunde prin e-mail lui