Patch 8.2.4185
Problem: Cannot use an import in 'indentexpr'.
Solution: Set the script context when evaluating 'indentexpr'
Files: src/indent.c, src/testdir/test_vim9_import.vim
*** ../vim-8.2.4184/src/indent.c 2022-01-15 10:00:59.576603900 +0000
--- src/indent.c 2022-01-22 20:29:09.879173230 +0000
***************
*** 1829,1834 ****
--- 1829,1835 ----
int save_State;
int use_sandbox = was_set_insecurely((char_u *)"indentexpr",
OPT_LOCAL);
+ sctx_T save_sctx = current_sctx;
// Save and restore cursor position and curswant, in case it was changed
// via :normal commands
***************
*** 1839,1844 ****
--- 1840,1846 ----
if (use_sandbox)
++sandbox;
++textwinlock;
+ current_sctx = curbuf->b_p_script_ctx[BV_INDE];
// Need to make a copy, the 'indentexpr' option could be changed while
// evaluating it.
***************
*** 1852,1857 ****
--- 1854,1860 ----
if (use_sandbox)
--sandbox;
--textwinlock;
+ current_sctx = save_sctx;
// Restore the cursor position so that 'indentexpr' doesn't need to.
// Pretend to be in Insert mode, allow cursor past end of line for "o"
*** ../vim-8.2.4184/src/testdir/test_vim9_import.vim 2022-01-22
20:19:15.751142312 +0000
--- src/testdir/test_vim9_import.vim 2022-01-22 20:27:37.533012504 +0000
***************
*** 817,822 ****
--- 817,849 ----
delete('Xthisfile')
enddef
+ def Test_import_in_indentexpr()
+ var lines =<< trim END
+ vim9script
+ export def GetIndent(): number
+ return 5
+ enddef
+ END
+ writefile(lines, 'Xindenter')
+
+ lines =<< trim END
+ vim9script
+ import './Xindenter' as indent
+ set indentexpr=indent.GetIndent()
+ set debug=throw
+ END
+ CheckScriptSuccess(lines)
+
+ new
+ setline(1, 'hello')
+ normal ==
+ assert_equal(' hello', getline(1))
+
+ bwipe!
+ set indentexpr= debug=
+ delete('Xindenter')
+ enddef
+
def Test_export_fails()
CheckScriptFailure(['export var some = 123'], 'E1042:')
CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
*** ../vim-8.2.4184/src/version.c 2022-01-22 20:19:15.751142312 +0000
--- src/version.c 2022-01-22 20:30:29.925582950 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4185,
/**/
--
ARTHUR: But if he was dying, he wouldn't bother to carve
"Aaaaarrrrrrggghhh". He'd just say it.
BROTHER MAYNARD: It's down there carved in stone.
GALAHAD: Perhaps he was dictating.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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/20220122203301.C04331C11B3%40moolenaar.net.