feat(options): add 'eventignorewin' (#32152)

vim-patch:partial:9.1.1084: Unable to persistently ignore events in a window and its buffers

Problem:  Unable to persistently ignore events in a window and its buffers.
Solution: Add 'eventignorewin' option to ignore events in a window and buffer
          (Luuk van Baal)

Add the window-local 'eventignorewin' option that is analogous to
'eventignore', but applies to a certain window and its buffers. Identify
events that should be allowed in 'eventignorewin', adapt "auto_event"
and "event_tab" to encode this information. Window context is not passed
onto apply_autocmds_group(), and when to ignore an event is a bit
ambiguous when "buf" is not "curbuf", rather than a large refactor, only
ignore an event when all windows into "buf" are ignoring the event.

b7147f8236

vim-patch:9.1.1102: tests: Test_WinScrolled_Resized_eiw() uses wrong filename

Problem:  tests: Test_WinScrolled_Resized_eiw() uses wrong filename
          (Luuk van Baal, after v9.1.1084)
Solution: Rename the filename to something more unique

bfc7719e48
This commit is contained in:
luukvbaal
2025-02-12 11:01:06 +01:00
committed by GitHub
parent 6982106f8c
commit 82a215cb2d
19 changed files with 406 additions and 259 deletions

View File

@@ -5530,31 +5530,20 @@ static dict_T *make_win_info_dict(int width, int height, int topline, int topfil
return NULL;
}
/// Return values of check_window_scroll_resize():
enum {
CWSR_SCROLLED = 1, ///< at least one window scrolled
CWSR_RESIZED = 2, ///< at least one window size changed
};
/// This function is used for three purposes:
/// 1. Goes over all windows in the current tab page and returns:
/// 0 no scrolling and no size changes found
/// CWSR_SCROLLED at least one window scrolled
/// CWSR_RESIZED at least one window changed size
/// CWSR_SCROLLED + CWSR_RESIZED both
/// "size_count" is set to the nr of windows with size changes.
/// "first_scroll_win" is set to the first window with any relevant changes.
/// "first_size_win" is set to the first window with size changes.
/// 1. Goes over all windows in the current tab page and sets:
/// "size_count" to the nr of windows with size changes.
/// "first_scroll_win" to the first window with any relevant changes.
/// "first_size_win" to the first window with size changes.
///
/// 2. When the first three arguments are NULL and "winlist" is not NULL,
/// "winlist" is set to the list of window IDs with size changes.
///
/// 3. When the first three arguments are NULL and "v_event" is not NULL,
/// information about changed windows is added to "v_event".
static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
win_T **first_size_win, list_T *winlist, dict_T *v_event)
static void check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
win_T **first_size_win, list_T *winlist, dict_T *v_event)
{
int result = 0;
// int listidx = 0;
int tot_width = 0;
int tot_height = 0;
@@ -5576,10 +5565,11 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
continue;
}
const bool size_changed = wp->w_last_width != wp->w_width
|| wp->w_last_height != wp->w_height;
const bool ignore_scroll = event_ignored(EVENT_WINSCROLLED, wp->w_p_eiw);
const bool size_changed = !event_ignored(EVENT_WINRESIZED, wp->w_p_eiw)
&& (wp->w_last_width != wp->w_width
|| wp->w_last_height != wp->w_height);
if (size_changed) {
result |= CWSR_RESIZED;
if (winlist != NULL) {
// Add this window to the list of changed windows.
typval_T tv = {
@@ -5597,21 +5587,19 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
}
// For WinScrolled the first window with a size change is used
// even when it didn't scroll.
if (*first_scroll_win == NULL) {
if (*first_scroll_win == NULL && !ignore_scroll) {
*first_scroll_win = wp;
}
}
}
const bool scroll_changed = wp->w_last_topline != wp->w_topline
|| wp->w_last_topfill != wp->w_topfill
|| wp->w_last_leftcol != wp->w_leftcol
|| wp->w_last_skipcol != wp->w_skipcol;
if (scroll_changed) {
result |= CWSR_SCROLLED;
if (first_scroll_win != NULL && *first_scroll_win == NULL) {
*first_scroll_win = wp;
}
const bool scroll_changed = !ignore_scroll
&& (wp->w_last_topline != wp->w_topline
|| wp->w_last_topfill != wp->w_topfill
|| wp->w_last_leftcol != wp->w_leftcol
|| wp->w_last_skipcol != wp->w_skipcol);
if (scroll_changed && first_scroll_win != NULL && *first_scroll_win == NULL) {
*first_scroll_win = wp;
}
if ((size_changed || scroll_changed) && v_event != NULL) {
@@ -5655,8 +5643,6 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
}
}
}
return result;
}
/// Trigger WinScrolled and/or WinResized if any window in the current tab page
@@ -5676,11 +5662,9 @@ void may_trigger_win_scrolled_resized(void)
int size_count = 0;
win_T *first_scroll_win = NULL;
win_T *first_size_win = NULL;
int cwsr = check_window_scroll_resize(&size_count,
&first_scroll_win, &first_size_win,
NULL, NULL);
check_window_scroll_resize(&size_count, &first_scroll_win, &first_size_win, NULL, NULL);
bool trigger_resize = do_resize && size_count > 0;
bool trigger_scroll = do_scroll && cwsr != 0;
bool trigger_scroll = do_scroll && first_scroll_win != NULL;
if (!trigger_resize && !trigger_scroll) {
return; // no relevant changes
}