diff src/window.c @ 22713:e871a824efc9 v8.2.1905

patch 8.2.1905: the wininfo list may contain stale entries Commit: https://github.com/vim/vim/commit/4882d983397057ea91c584c5a54aaccf15016d18 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 25 17:55:09 2020 +0100 patch 8.2.1905: the wininfo list may contain stale entries Problem: The wininfo list may contain stale entries. Solution: When closing a window remove any other entry where the window pointer is NULL.
author Bram Moolenaar <Bram@vim.org>
date Sun, 25 Oct 2020 18:00:04 +0100
parents e82579016863
children 8e7cbf73c3a0
line wrap: on
line diff
--- a/src/window.c
+++ b/src/window.c
@@ -5015,7 +5015,26 @@ win_free(
     FOR_ALL_BUFFERS(buf)
 	FOR_ALL_BUF_WININFO(buf, wip)
 	    if (wip->wi_win == wp)
+	    {
+		wininfo_T	*wip2;
+
+		// If there already is an entry with "wi_win" set to NULL it
+		// must be removed, it would never be used.
+		for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next)
+		    if (wip2->wi_win == NULL)
+		    {
+			if (wip2->wi_next != NULL)
+			    wip2->wi_next->wi_prev = wip2->wi_prev;
+			if (wip2->wi_prev == NULL)
+			    buf->b_wininfo = wip2->wi_next;
+			else
+			    wip2->wi_prev->wi_next = wip2->wi_next;
+			free_wininfo(wip2);
+			break;
+		    }
+
 		wip->wi_win = NULL;
+	    }
 
 #ifdef FEAT_SEARCH_EXTRA
     clear_matches(wp);