Navigation Menu

Skip to content

Commit

Permalink
patch 8.2.3610: crash when ModeChanged triggered too early
Browse files Browse the repository at this point in the history
Problem:    Crash when ModeChanged triggered too early.
Solution:   Trigger ModeChanged after setting VIsual.
  • Loading branch information
brammool committed Nov 17, 2021
1 parent 3075a45 commit a062006
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/normal.c
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion src/testdir/test_edit.vim
Expand Up @@ -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-^
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3610,
/**/
3609,
/**/
Expand Down

0 comments on commit a062006

Please sign in to comment.