Patch 8.2.4184
Problem: Cannot use an import in 'includeexpr'.
Solution: Set the script context when evaluating 'includeexpr'
Files: src/findfile.c, src/testdir/test_vim9_import.vim
*** ../vim-8.2.4183/src/findfile.c 2022-01-22 13:39:04.103476264 +0000
--- src/findfile.c 2022-01-22 20:16:41.266336590 +0000
***************
*** 2094,2104 ****
eval_includeexpr(char_u *ptr, int len)
{
char_u *res;
set_vim_var_string(VV_FNAME, ptr, len);
res = eval_to_string_safe(curbuf->b_p_inex,
! was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL), FALSE);
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}
# endif
--- 2094,2109 ----
eval_includeexpr(char_u *ptr, int len)
{
char_u *res;
+ sctx_T save_sctx = current_sctx;
set_vim_var_string(VV_FNAME, ptr, len);
+ current_sctx = curbuf->b_p_script_ctx[BV_INEX];
+
res = eval_to_string_safe(curbuf->b_p_inex,
! was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL), TRUE);
!
set_vim_var_string(VV_FNAME, NULL, 0);
+ current_sctx = save_sctx;
return res;
}
# endif
*** ../vim-8.2.4183/src/testdir/test_vim9_import.vim 2022-01-22
19:17:27.219225083 +0000
--- src/testdir/test_vim9_import.vim 2022-01-22 20:15:54.095322847 +0000
***************
*** 787,792 ****
--- 787,822 ----
set formatexpr=
enddef
+ def Test_import_in_includeexpr()
+ writefile(['found it'], 'Xthisfile')
+ new
+
+ var lines =<< trim END
+ vim9script
+ export def DoSub(): string
+ return substitute(v:fname, 'that', 'this', '')
+ enddef
+ END
+ writefile(lines, 'Xinclude.vim')
+
+ lines =<< trim END
+ vim9script
+ import './Xinclude.vim'
+ set includeexpr=Xinclude.DoSub()
+ END
+ CheckScriptSuccess(lines)
+
+ setline(1, ['Xthatfile'])
+ exe "normal \<C-W>f"
+ assert_equal('Xthisfile', expand('%'))
+
+ bwipe!
+ bwipe!
+ set includeexpr=
+ delete('Xinclude')
+ delete('Xthisfile')
+ enddef
+
def Test_export_fails()
CheckScriptFailure(['export var some = 123'], 'E1042:')
CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
*** ../vim-8.2.4183/src/version.c 2022-01-22 19:17:27.219225083 +0000
--- src/version.c 2022-01-22 19:49:32.887771493 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4184,
/**/
--
Veni, Vidi, VW -- I came, I saw, I drove around in a little car.
/// 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/20220122201958.8E01C1C11B3%40moolenaar.net.