changeset 26157:20200363816c v8.2.3610

patch 8.2.3610: crash when ModeChanged triggered too early Commit: https://github.com/vim/vim/commit/a062006b9de0b2947ab5fb376c6e67ef92a8cd69 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 17 16:52:40 2021 +0000 patch 8.2.3610: crash when ModeChanged triggered too early Problem: Crash when ModeChanged triggered too early. Solution: Trigger ModeChanged after setting VIsual.
author Bram Moolenaar <Bram@vim.org>
date Wed, 17 Nov 2021 18:00:05 +0100
parents ebedb61a4b9b
children 9b1f90bc52dc
files src/normal.c src/testdir/test_edit.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -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.
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -2037,7 +2037,15 @@ endfunc
 func Test_recursive_ModeChanged()
   au! ModeChanged * norm 0u
   sil! norm 
-  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 
+
+  au! ModeChanged
 endfunc
 
 " Test toggling of input method. See :help i_CTRL-^
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3610,
+/**/
     3609,
 /**/
     3608,