comparison src/autocmd.c @ 31166:a86ee6c0309e v9.0.0917

patch 9.0.0917: the WinScrolled autocommand event is not enough Commit: https://github.com/vim/vim/commit/35fc61cb5b5eba8bbb9d8f0700332fbab38f40ca Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 22 12:40:50 2022 +0000 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)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Nov 2022 13:45:04 +0100
parents 981f7bc781bb
children d8e7d725a666
comparison
equal deleted inserted replaced
31165:b1c24c44852a 31166:a86ee6c0309e
189 {"VimLeavePre", EVENT_VIMLEAVEPRE}, 189 {"VimLeavePre", EVENT_VIMLEAVEPRE},
190 {"WinNew", EVENT_WINNEW}, 190 {"WinNew", EVENT_WINNEW},
191 {"WinClosed", EVENT_WINCLOSED}, 191 {"WinClosed", EVENT_WINCLOSED},
192 {"WinEnter", EVENT_WINENTER}, 192 {"WinEnter", EVENT_WINENTER},
193 {"WinLeave", EVENT_WINLEAVE}, 193 {"WinLeave", EVENT_WINLEAVE},
194 {"WinResized", EVENT_WINRESIZED},
194 {"WinScrolled", EVENT_WINSCROLLED}, 195 {"WinScrolled", EVENT_WINSCROLLED},
195 {"VimResized", EVENT_VIMRESIZED}, 196 {"VimResized", EVENT_VIMRESIZED},
196 {"TextYankPost", EVENT_TEXTYANKPOST}, 197 {"TextYankPost", EVENT_TEXTYANKPOST},
197 {"VimSuspend", EVENT_VIMSUSPEND}, 198 {"VimSuspend", EVENT_VIMSUSPEND},
198 {"VimResume", EVENT_VIMRESUME}, 199 {"VimResume", EVENT_VIMRESUME},
1261 // need to initialize last_mode for the first ModeChanged 1262 // need to initialize last_mode for the first ModeChanged
1262 // autocmd 1263 // autocmd
1263 if (event == EVENT_MODECHANGED && !has_modechanged()) 1264 if (event == EVENT_MODECHANGED && !has_modechanged())
1264 get_mode(last_mode); 1265 get_mode(last_mode);
1265 #endif 1266 #endif
1266 // Initialize the fields checked by the WinScrolled trigger to 1267 // Initialize the fields checked by the WinScrolled and
1267 // prevent it from firing right after the first autocmd is 1268 // WinResized trigger to prevent them from firing right after
1268 // defined. 1269 // the first autocmd is defined.
1269 if (event == EVENT_WINSCROLLED && !has_winscrolled()) 1270 if ((event == EVENT_WINSCROLLED || event == EVENT_WINRESIZED)
1271 && !(has_winscrolled() || has_winresized()))
1270 { 1272 {
1271 tabpage_T *save_curtab = curtab; 1273 tabpage_T *save_curtab = curtab;
1272 tabpage_T *tp; 1274 tabpage_T *tp;
1273 FOR_ALL_TABPAGES(tp) 1275 FOR_ALL_TABPAGES(tp)
1274 { 1276 {
1806 state = get_real_state(); 1808 state = get_real_state();
1807 if (state == MODE_NORMAL_BUSY || (state & MODE_INSERT) != 0) 1809 if (state == MODE_NORMAL_BUSY || (state & MODE_INSERT) != 0)
1808 return TRUE; 1810 return TRUE;
1809 } 1811 }
1810 return FALSE; 1812 return FALSE;
1813 }
1814
1815 /*
1816 * Return TRUE when there is a WinResized autocommand defined.
1817 */
1818 int
1819 has_winresized(void)
1820 {
1821 return (first_autopat[(int)EVENT_WINRESIZED] != NULL);
1811 } 1822 }
1812 1823
1813 /* 1824 /*
1814 * Return TRUE when there is a WinScrolled autocommand defined. 1825 * Return TRUE when there is a WinScrolled autocommand defined.
1815 */ 1826 */
2115 || event == EVENT_DIRCHANGEDPRE 2126 || event == EVENT_DIRCHANGEDPRE
2116 || event == EVENT_MODECHANGED 2127 || event == EVENT_MODECHANGED
2117 || event == EVENT_MENUPOPUP 2128 || event == EVENT_MENUPOPUP
2118 || event == EVENT_USER 2129 || event == EVENT_USER
2119 || event == EVENT_WINCLOSED 2130 || event == EVENT_WINCLOSED
2131 || event == EVENT_WINRESIZED
2120 || event == EVENT_WINSCROLLED) 2132 || event == EVENT_WINSCROLLED)
2121 { 2133 {
2122 fname = vim_strsave(fname); 2134 fname = vim_strsave(fname);
2123 autocmd_fname_full = TRUE; // don't expand it later 2135 autocmd_fname_full = TRUE; // don't expand it later
2124 } 2136 }