summaryrefslogtreecommitdiff
path: root/src/autocmd.c
diff options
context:
space:
mode:
author=?UTF-8?q?Magnus=20Gro=C3=9F?= <magnus.gross@rwth-aachen.de>2021-10-22 18:56:39 +0100
committerBram Moolenaar <Bram@vim.org>2021-10-22 18:56:39 +0100
commit25def2c8b8bd7b0c3d5f020207c717a880b05d50 (patch)
tree297dc3f2ad09266c34bdf4c518ff5ebcc588bb4d /src/autocmd.c
parenta2ffb435209716dc7aeb4783333f6ea19f5d28a7 (diff)
downloadvim-git-25def2c8b8bd7b0c3d5f020207c717a880b05d50.tar.gz
patch 8.2.3555: ModeChanged is not triggered on every mode changev8.2.3555
Problem: ModeChanged is not triggered on every mode change. Solution: Also trigger on minor mode changes. (Maguns Gross, closes #8999)
Diffstat (limited to 'src/autocmd.c')
-rw-r--r--src/autocmd.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index bd1ed8741..1704cd4e3 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1218,6 +1218,23 @@ do_autocmd_event(
return FAIL;
}
+#ifdef FEAT_EVAL
+ // need to initialize last_mode for the first ModeChanged
+ // autocmd
+ if (event == EVENT_MODECHANGED && !has_modechanged())
+ {
+ typval_T rettv;
+ typval_T tv[2];
+
+ tv[0].v_type = VAR_NUMBER;
+ tv[0].vval.v_number = 1;
+ tv[1].v_type = VAR_UNKNOWN;
+ f_mode(tv, &rettv);
+ STRCPY(last_mode, rettv.vval.v_string);
+ vim_free(rettv.vval.v_string);
+ }
+#endif
+
if (is_buflocal)
{
ap->buflocal_nr = buflocal_nr;