Patch 8.2.4197

6 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 23, 2022, 12:59:41 PM1/23/22
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages