]> granicus.if.org Git - vim/commitdiff
patch 8.2.3610: crash when ModeChanged triggered too early v8.2.3610
authorBram Moolenaar <Bram@vim.org>
Wed, 17 Nov 2021 16:52:40 +0000 (16:52 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 17 Nov 2021 16:52:40 +0000 (16:52 +0000)
Problem:    Crash when ModeChanged triggered too early.
Solution:   Trigger ModeChanged after setting VIsual.

src/normal.c
src/testdir/test_edit.vim
src/version.c

index 11b61f92a6cf9644d0a2c318e79d0777605c4688..059baee90faabe790fb8d364b2ba78e16e7b8f2a 100644 (file)
@@ -5778,7 +5778,6 @@ n_start_visual_mode(int c)
     VIsual_mode = c;
     VIsual_active = TRUE;
     VIsual_reselect = TRUE;
-    trigger_modechanged();
 
     // Corner case: the 0 position in a tab may change when going into
     // virtualedit.  Recalculate curwin->w_cursor to avoid bad highlighting.
@@ -5793,6 +5792,7 @@ n_start_visual_mode(int c)
     foldAdjustVisual();
 #endif
 
+    trigger_modechanged();
     setmouse();
 #ifdef FEAT_CONCEAL
     // Check if redraw is needed after changing the state.
index 957f248fc737db5ec09859c292fa53db5b721532..bea1b762ee78edae5c01f0a3fd67c406d603e4b1 100644 (file)
@@ -2037,7 +2037,15 @@ endfunc
 func Test_recursive_ModeChanged()
   au! ModeChanged * norm 0u
   sil! norm \16
-  au!
+  au! ModeChanged
+endfunc
+
+func Test_ModeChanged_starts_visual()
+  " This was triggering ModeChanged before setting VIsual, causing a crash.
+  au! ModeChanged * norm 0u
+  sil! norm \16
+
+  au! ModeChanged
 endfunc
 
 " Test toggling of input method. See :help i_CTRL-^
index 55928db1963c12cef27bf8159810736383175d9a..d301120079e6910dd29b59fc08a8a981aa0ae200 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3610,
 /**/
     3609,
 /**/