diff src/misc1.c @ 30908:11115c806541 v9.0.0788

patch 9.0.0788: ModeChanged autocmd not executed when Visual ends with CTRL-C Commit: https://github.com/vim/vim/commit/61c4b04799bf114cadc3bbf212ae8b2ad22a6980 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 18 15:10:11 2022 +0100 patch 9.0.0788: ModeChanged autocmd not executed when Visual ends with CTRL-C Problem: ModeChanged autocmd not executed when Visual mode is ended with CTRL-C. Solution: Do not trigger the autocmd when got_int is set. (closes #11394)
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Oct 2022 16:15:04 +0200
parents 0d084880276a
children 238ca27dbfd2
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -330,6 +330,7 @@ get_last_leader_offset(char_u *line, cha
 
 /*
  * Return the number of window lines occupied by buffer line "lnum".
+ * Includes any filler lines.
  */
     int
 plines(linenr_T lnum)
@@ -349,6 +350,10 @@ plines_win(
     return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum);
 }
 
+/*
+ * Return the number of window lines occupied by buffer line "lnum".
+ * Does not include filler lines.
+ */
     int
 plines_nofill(linenr_T lnum)
 {
@@ -2754,7 +2759,9 @@ may_trigger_modechanged()
     char_u	    curr_mode[MODE_MAX_LENGTH];
     char_u	    pattern_buf[2 * MODE_MAX_LENGTH];
 
-    if (!has_modechanged())
+    // Skip this when got_int is set, the autocommand will not be executed.
+    // Better trigger it next time.
+    if (!has_modechanged() || got_int)
 	return;
 
     get_mode(curr_mode);