# HG changeset patch # User Bram Moolenaar # Date 1653568203 -7200 # Node ID 54247d52bee9bfa9cbda5e638d6d9847e9491bdf # Parent bb0a5cc369bb8b30a3c98e6b37a570d4bef30096 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen' Commit: https://github.com/vim/vim/commit/c7e54efe4dc2bd8fd86feb4a26b4485b7b4c8578 Author: Milly Date: Thu May 26 13:16:25 2022 +0100 patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen' Problem: Using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'. Solution: Save and restore the KeyTyped flag. (closes https://github.com/vim/vim/issues/10479) diff --git a/src/gui_xim.c b/src/gui_xim.c --- a/src/gui_xim.c +++ b/src/gui_xim.c @@ -89,17 +89,21 @@ set_imstatusfunc_option(void) call_imactivatefunc(int active) { typval_T argv[2]; + int save_KeyTyped = KeyTyped; argv[0].v_type = VAR_NUMBER; argv[0].vval.v_number = active ? 1 : 0; argv[1].v_type = VAR_UNKNOWN; (void)call_callback_retnr(&imaf_cb, 1, argv); + + KeyTyped = save_KeyTyped; } static int call_imstatusfunc(void) { int is_active; + int save_KeyTyped = KeyTyped; // FIXME: Don't execute user function in unsafe situation. if (exiting || is_autocmd_blocked()) @@ -109,6 +113,8 @@ call_imstatusfunc(void) ++msg_silent; is_active = call_callback_retnr(&imsf_cb, 0, NULL); --msg_silent; + + KeyTyped = save_KeyTyped; return (is_active > 0); } #endif diff --git a/src/testdir/test_iminsert.vim b/src/testdir/test_iminsert.vim --- a/src/testdir/test_iminsert.vim +++ b/src/testdir/test_iminsert.vim @@ -63,6 +63,35 @@ func Test_getimstatus() set imstatusfunc= endfunc +func Test_imactivatefunc_imstatusfunc_callback_no_breaks_foldopen() + CheckScreendump + + let lines =<< trim END + func IM_activatefunc(active) + endfunc + func IM_statusfunc() + return 0 + endfunc + set imactivatefunc=IM_activatefunc + set imstatusfunc=IM_statusfunc + set foldmethod=marker + set foldopen=search + call setline(1, ['{{{', 'abc', '}}}']) + %foldclose + END + call writefile(lines, 'Xscript') + let buf = RunVimInTerminal('-S Xscript', {}) + call term_wait(buf) + call assert_notequal('abc', term_getline(buf, 2)) + call term_sendkeys(buf, "/abc\n") + call term_wait(buf) + call assert_equal('abc', term_getline(buf, 2)) + + " clean up + call StopVimInTerminal(buf) + call delete('Xscript') +endfunc + " Test for using an lmap in insert mode func Test_lmap_in_insert_mode() new diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 5020, +/**/ 5019, /**/ 5018,