]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5020: using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen' v8.2.5020
authorMilly <milly.ca@gmail.com>
Thu, 26 May 2022 12:16:25 +0000 (13:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 26 May 2022 12:16:25 +0000 (13:16 +0100)
Problem:    Using 'imstatusfunc' and 'imactivatefunc' breaks 'foldopen'.
Solution:   Save and restore the KeyTyped flag. (closes #10479)

src/gui_xim.c
src/testdir/test_iminsert.vim
src/version.c

index 9f3181e76946903c913da07e56118ccdec2c3fae..4d8706a100b589ea60fd391aa7ca3c91801af2db 100644 (file)
@@ -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
index e5ded5866c5364078f548a6e74afeffc51a09b40..a0e9db0a78514bd70e90c76f3d3608056772704f 100644 (file)
@@ -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
index 9589d792c87f858c487274c0f9acb26d14759089..6a6f07dab7f179aa31cfd125059fa5af1d0a5220 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5020,
 /**/
     5019,
 /**/