patch 9.1.1380: 'eventignorewin' only checked for current buffer

Problem:  When an autocommand executes for a non-current buffer,
          'eventignorewin' is only checked from the buffer's last
          wininfo (overwrites win_ignore in the loop), not from the
          value of 'eventignorewin' in all windows showing the buffer as
          described (after v9.1.1084)

Solution: Fix the check and don't use wininfo, as that may only contain
          windows that recently showed the buffer. Consider all the
          buffer's windows in all tabpages (Sean Dewar).

closes: #17294

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/autocmd.c b/src/autocmd.c
index 6ee6c11..3d21a93 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -2135,16 +2135,24 @@
     if (event_ignored(event, p_ei))
 	goto BYPASS_AU;
 
-    wininfo_T *wip;
     int win_ignore = FALSE;
     // If event is allowed in 'eventignorewin', check if curwin or all windows
     // into "buf" are ignoring the event.
     if (buf == curbuf && event_tab[event].key <= 0)
 	win_ignore = event_ignored(event, curwin->w_p_eiw);
-    else if (buf != NULL && event_tab[event].key <= 0)
-	FOR_ALL_BUF_WININFO(buf, wip)
-	    if (wip->wi_win != NULL && wip->wi_win->w_buffer == buf)
-		win_ignore = event_ignored(event, wip->wi_win->w_p_eiw);
+    else if (buf != NULL && event_tab[event].key <= 0 && buf->b_nwindows > 0)
+    {
+	tabpage_T *tp;
+	win_T *wp;
+
+	win_ignore = TRUE;
+	FOR_ALL_TAB_WINDOWS(tp, wp)
+	    if (wp->w_buffer == buf && !event_ignored(event, wp->w_p_eiw))
+	    {
+		win_ignore = FALSE;
+		break;
+	    }
+    }
     if (win_ignore)
 	goto BYPASS_AU;