Patch 8.2.4197
Problem: Cannot use an import in the "expr" part of 'spellsuggest'.
Solution: Set the script context when evaluating "expr" of 'spellsuggest'.
Files: src/evalvars.c, src/testdir/test_vim9_import.vim
*** ../vim-8.2.4196/src/evalvars.c 2022-01-23 14:17:24.631509344 +0000
--- src/evalvars.c 2022-01-23 17:56:36.776920357 +0000
***************
*** 495,506 ****
--- 495,511 ----
typval_T rettv;
list_T *list = NULL;
char_u *p = skipwhite(expr);
+ sctx_T saved_sctx = current_sctx;
+ sctx_T *ctx;
// Set "v:val" to the bad word.
prepare_vimvar(VV_VAL, &save_val);
set_vim_var_string(VV_VAL, badword, -1);
if (p_verbose == 0)
++emsg_off;
+ ctx = get_option_sctx("spellsuggest");
+ if (ctx != NULL)
+ current_sctx = *ctx;
if (eval1(&p, &rettv, &EVALARG_EVALUATE) == OK)
{
***************
*** 514,519 ****
--- 519,525 ----
--emsg_off;
clear_tv(get_vim_var_tv(VV_VAL));
restore_vimvar(VV_VAL, &save_val);
+ current_sctx = saved_sctx;
return list;
}
*** ../vim-8.2.4196/src/testdir/test_vim9_import.vim 2022-01-23
14:17:24.631509344 +0000
--- src/testdir/test_vim9_import.vim 2022-01-23 17:55:55.641699830 +0000
***************
*** 936,941 ****
--- 936,969 ----
set charconvert&
enddef
+ func Test_import_in_spellsuggest_expr()
+ CheckFeature spell
+ call Run_Test_import_in_spellsuggest_expr()
+ endfunc
+
+ def Run_Test_import_in_spellsuggest_expr()
+ var lines =<< trim END
+ vim9script
+ export def MySuggest(): list<any>
+ return [['Fox', 8], ['Fop', 9]]
+ enddef
+ END
+ writefile(lines, 'Xsuggest.vim')
+
+ lines =<< trim END
+ vim9script
+ import './Xsuggest.vim' as sugg
+ set spell spellsuggest=expr:sugg.MySuggest()
+ END
+ CheckScriptSuccess(lines)
+
+ set verbose=1 # report errors
+ call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2))
+
+ delete('Xsuggest.vim')
+ set nospell spellsuggest& verbose=0
+ enddef
+
def Test_export_fails()
CheckScriptFailure(['export var some = 123'], 'E1042:')
CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:')
*** ../vim-8.2.4196/src/version.c 2022-01-23 17:09:00.342463158 +0000
--- src/version.c 2022-01-23 17:31:00.121852152 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4197,
/**/
--
Q: Why does /dev/null accept only integers?
A: You can't sink a float.
/// 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/20220123175935.7D0101C44F7%40moolenaar.net.