Patch 9.0.0961
Problem:    Using deletebufline() may jump to another window.
Solution:   Do not use a window where the buffer was only in the past.
            (closes #11594)
Files:      src/evalbuffer.c, src/testdir/test_bufline.vim


*** ../vim-9.0.0960/src/evalbuffer.c    2022-11-21 19:56:59.403412744 +0000
--- src/evalbuffer.c    2022-11-27 19:37:48.341094310 +0000
***************
*** 109,117 ****
  {
      wininfo_T *wip;
  
      FOR_ALL_BUF_WININFO(curbuf, wip)
      {
!       if (wip->wi_win != NULL)
        {
            curwin = wip->wi_win;
            break;
--- 109,120 ----
  {
      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 && wip->wi_win->w_buffer == curbuf)
        {
            curwin = wip->wi_win;
            break;
*** ../vim-9.0.0960/src/testdir/test_bufline.vim        2022-11-21 
19:56:59.403412744 +0000
--- src/testdir/test_bufline.vim        2022-11-27 19:30:22.429475875 +0000
***************
*** 288,293 ****
--- 288,307 ----
    bwipe!
  endfunc
  
+ func Test_deletebufline_popup_window()
+   let popupID = popup_create('foo', {})
+   let bufnr = winbufnr(popupID)
+ 
+   " Check that deletebufline() brings us back to the same window.
+   new
+   let winid_before = win_getid()
+   call deletebufline(bufnr, 1, '$')
+   call assert_equal(winid_before, win_getid())
+   bwipe
+ 
+   call popup_close(popupID)
+ endfunc
+ 
  func Test_setbufline_startup_nofile()
    let before =<< trim [CODE]
      set shortmess+=F
*** ../vim-9.0.0960/src/version.c       2022-11-27 16:18:30.267345906 +0000
--- src/version.c       2022-11-27 19:31:38.050297301 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     961,
  /**/

-- 
You're as much use as a condom machine at the Vatican.
                  -- Rimmer to Holly in Red Dwarf 'Queeg'

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221127194617.8D4AB1C09D0%40moolenaar.net.

Raspunde prin e-mail lui