summaryrefslogtreecommitdiffstats
path: root/src/autocmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-11-22 12:40:50 +0000
committerBram Moolenaar <Bram@vim.org>2022-11-22 12:40:50 +0000
commit35fc61cb5b5eba8bbb9d8f0700332fbab38f40ca (patch)
tree352599f641e6c8c88d8574871f8b8e86b6168dba /src/autocmd.c
parentce30ccc06af7f2c03762e5b18dde37b26ea6ec42 (diff)
patch 9.0.0917: the WinScrolled autocommand event is not enoughv9.0.0917
Problem: The WinScrolled autocommand event is not enough. Solution: Add WinResized and provide information about what changed. (closes #11576)
Diffstat (limited to 'src/autocmd.c')
-rw-r--r--src/autocmd.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 999ee890cb..11dc707d74 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -191,6 +191,7 @@ static struct event_name
{"WinClosed", EVENT_WINCLOSED},
{"WinEnter", EVENT_WINENTER},
{"WinLeave", EVENT_WINLEAVE},
+ {"WinResized", EVENT_WINRESIZED},
{"WinScrolled", EVENT_WINSCROLLED},
{"VimResized", EVENT_VIMRESIZED},
{"TextYankPost", EVENT_TEXTYANKPOST},
@@ -1263,10 +1264,11 @@ do_autocmd_event(
if (event == EVENT_MODECHANGED && !has_modechanged())
get_mode(last_mode);
#endif
- // Initialize the fields checked by the WinScrolled trigger to
- // prevent it from firing right after the first autocmd is
- // defined.
- if (event == EVENT_WINSCROLLED && !has_winscrolled())
+ // Initialize the fields checked by the WinScrolled and
+ // WinResized trigger to prevent them from firing right after
+ // the first autocmd is defined.
+ if ((event == EVENT_WINSCROLLED || event == EVENT_WINRESIZED)
+ && !(has_winscrolled() || has_winresized()))
{
tabpage_T *save_curtab = curtab;
tabpage_T *tp;
@@ -1811,6 +1813,15 @@ trigger_cursorhold(void)
}
/*
+ * Return TRUE when there is a WinResized autocommand defined.
+ */
+ int
+has_winresized(void)
+{
+ return (first_autopat[(int)EVENT_WINRESIZED] != NULL);
+}
+
+/*
* Return TRUE when there is a WinScrolled autocommand defined.
*/
int
@@ -2117,6 +2128,7 @@ apply_autocmds_group(
|| event == EVENT_MENUPOPUP
|| event == EVENT_USER
|| event == EVENT_WINCLOSED
+ || event == EVENT_WINRESIZED
|| event == EVENT_WINSCROLLED)
{
fname = vim_strsave(fname);