From 69bd1e4e36fa3e3f604740c92b15b13141520822 Mon Sep 17 00:00:00 2001 From: Magnus Groß Date: Wed, 29 Sep 2021 16:36:48 +0200 Subject: vim-patch:8.2.3430: no generic way to trigger an autocommand on mode change Problem: No generic way to trigger an autocommand on mode change. Solution: Add the ModeChanged autocommand event. (Magnus Gross, closes vim/vim#8856) https://github.com/vim/vim/commit/f1e8876fa2359b572d262772747405d3616db670 N/A patches for version.c: vim-patch:8.2.3434: function prototype for trigger_modechanged() is incomplete Problem: Function prototype for trigger_modechanged() is incomplete. Solution: Add "void". https://github.com/vim/vim/commit/28e591dd5080bbcd0f468f9d9597cedb716e28c9 Fixes #4399. Fixes #7416. --- src/nvim/normal.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1effeefd32..81e8251361 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3050,6 +3050,7 @@ static int get_mouse_class(char_u *p) void end_visual_mode(void) { VIsual_active = false; + trigger_modechanged(); setmouse(); mouse_dragging = 0; @@ -6680,6 +6681,7 @@ static void nv_visual(cmdarg_T *cap) // or char/line mode VIsual_mode = cap->cmdchar; showmode(); + trigger_modechanged(); } redraw_curbuf_later(INVERTED); // update the inversion } else { // start Visual mode @@ -6782,6 +6784,7 @@ static void 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. // -- cgit From 11683193f597e1b3144ba65f08056cd44b19175f Mon Sep 17 00:00:00 2001 From: Magnus Groß Date: Fri, 22 Oct 2021 20:36:35 +0200 Subject: vim-patch:8.2.3555: ModeChanged is not triggered on every mode change Problem: ModeChanged is not triggered on every mode change. Solution: Also trigger on minor mode changes. (Maguns Gross, closes vim/vim#8999) https://github.com/vim/vim/commit/25def2c8b8bd7b0c3d5f020207c717a880b05d50 --- src/nvim/normal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 81e8251361..686eddfb14 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -487,6 +487,7 @@ static void normal_prepare(NormalState *s) if (finish_op != c) { ui_cursor_shape(); // may show different cursor shape } + trigger_modechanged(); // When not finishing an operator and no register name typed, reset the count. if (!finish_op && !s->oa.regname) { @@ -928,6 +929,7 @@ normal_end: // Reset finish_op, in case it was set s->c = finish_op; finish_op = false; + trigger_modechanged(); // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. if (s->c || s->ca.cmdchar == 'r') { @@ -965,6 +967,7 @@ normal_end: && s->oa.regname == 0) { if (restart_VIsual_select == 1) { VIsual_select = true; + trigger_modechanged(); showmode(); restart_VIsual_select = 0; } @@ -3050,7 +3053,6 @@ static int get_mouse_class(char_u *p) void end_visual_mode(void) { VIsual_active = false; - trigger_modechanged(); setmouse(); mouse_dragging = 0; @@ -3067,6 +3069,7 @@ void end_visual_mode(void) may_clear_cmdline(); adjust_cursor_eol(); + trigger_modechanged(); } /* @@ -4852,6 +4855,7 @@ static void nv_ctrlg(cmdarg_T *cap) { if (VIsual_active) { // toggle Selection/Visual mode VIsual_select = !VIsual_select; + trigger_modechanged(); showmode(); } else if (!checkclearop(cap->oap)) { // print full name if count given or :cd used @@ -4895,6 +4899,7 @@ static void nv_ctrlo(cmdarg_T *cap) { if (VIsual_active && VIsual_select) { VIsual_select = false; + trigger_modechanged(); showmode(); restart_VIsual_select = 2; // restart Select mode later } else { -- cgit From 980c68d0362c3ca099c0facef2d08efede76aabf Mon Sep 17 00:00:00 2001 From: Magnus Groß Date: Wed, 17 Nov 2021 18:31:51 +0100 Subject: vim-patch:8.2.3610: crash when ModeChanged triggered too early Problem: Crash when ModeChanged triggered too early. Solution: Trigger ModeChanged after setting VIsual. https://github.com/vim/vim/commit/a062006b9de0b2947ab5fb376c6e67ef92a8cd69 --- src/nvim/normal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/normal.c') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 686eddfb14..2ef15bde9b 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6789,7 +6789,6 @@ static void 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. // @@ -6801,6 +6800,7 @@ static void n_start_visual_mode(int c) foldAdjustVisual(); + trigger_modechanged(); setmouse(); // Check for redraw after changing the state. conceal_check_cursor_line(); -- cgit