patch 9.0.0961: using deletebufline() may jump to another window
Problem: Using deletebufline() may jump to another window.
Solution: Do not use a window where the buffer was only in the past.
(closes #11594)
diff --git a/src/evalbuffer.c b/src/evalbuffer.c
index 52662a6..82a10d6 100644
--- a/src/evalbuffer.c
+++ b/src/evalbuffer.c
@@ -109,9 +109,12 @@
{
wininfo_T *wip;
+ // The b_wininfo list should have the windows that recently contained the
+ // buffer, going over this is faster than going over all the windows.
+ // Do check the buffer is still there.
FOR_ALL_BUF_WININFO(curbuf, wip)
{
- if (wip->wi_win != NULL)
+ if (wip->wi_win != NULL && wip->wi_win->w_buffer == curbuf)
{
curwin = wip->wi_win;
break;