0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 9.0.0917: the WinScrolled autocommand event is not enough

Problem:    The WinScrolled autocommand event is not enough.
Solution:   Add WinResized and provide information about what changed.
            (closes #11576)
This commit is contained in:
Bram Moolenaar
2022-11-22 12:40:50 +00:00
parent ce30ccc06a
commit 35fc61cb5b
14 changed files with 461 additions and 60 deletions

View File

@@ -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;
@@ -1810,6 +1812,15 @@ trigger_cursorhold(void)
return FALSE;
}
/*
* 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.
*/
@@ -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);