Patch 8.2.4327
Problem:    May end up with no current buffer.
Solution:   When deleting the current buffer to not pick a quickfix buffer as
            the new current buffer.
Files:      src/buffer.c, src/testdir/test_quickfix.vim


*** ../vim-8.2.4326/src/buffer.c        2022-02-01 13:54:11.651302024 +0000
--- src/buffer.c        2022-02-08 15:00:52.496947059 +0000
***************
*** 1430,1437 ****
                buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
                if (buf != NULL)
                {
!                   if (buf == curbuf || !buf->b_p_bl)
!                       buf = NULL;     // skip current and unlisted bufs
                    else if (buf->b_ml.ml_mfp == NULL)
                    {
                        // skip unloaded buf, but may keep it for later
--- 1430,1443 ----
                buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
                if (buf != NULL)
                {
!                   // Skip current and unlisted bufs.  Also skip a quickfix
!                   // buffer, it might be deleted soon.
!                   if (buf == curbuf || !buf->b_p_bl
! #if defined(FEAT_QUICKFIX)
!                           || bt_quickfix(buf)
! #endif
!                           )
!                       buf = NULL;
                    else if (buf->b_ml.ml_mfp == NULL)
                    {
                        // skip unloaded buf, but may keep it for later
***************
*** 1467,1473 ****
                    continue;
                }
                // in non-help buffer, try to skip help buffers, and vv
!               if (buf->b_help == curbuf->b_help && buf->b_p_bl)
                {
                    if (buf->b_ml.ml_mfp != NULL)   // found loaded buffer
                        break;
--- 1473,1483 ----
                    continue;
                }
                // in non-help buffer, try to skip help buffers, and vv
!               if (buf->b_help == curbuf->b_help && buf->b_p_bl
! #if defined(FEAT_QUICKFIX)
!                           && !bt_quickfix(buf)
! #endif
!                          )
                {
                    if (buf->b_ml.ml_mfp != NULL)   // found loaded buffer
                        break;
***************
*** 1485,1491 ****
        if (buf == NULL)        // No loaded buffer, find listed one
        {
            FOR_ALL_BUFFERS(buf)
!               if (buf->b_p_bl && buf != curbuf)
                    break;
        }
        if (buf == NULL)        // Still no buffer, just take one
--- 1495,1505 ----
        if (buf == NULL)        // No loaded buffer, find listed one
        {
            FOR_ALL_BUFFERS(buf)
!               if (buf->b_p_bl && buf != curbuf
! #if defined(FEAT_QUICKFIX)
!                           && !bt_quickfix(buf)
! #endif
!                      )
                    break;
        }
        if (buf == NULL)        // Still no buffer, just take one
***************
*** 1494,1499 ****
--- 1508,1517 ----
                buf = curbuf->b_next;
            else
                buf = curbuf->b_prev;
+ #if defined(FEAT_QUICKFIX)
+           if (bt_quickfix(buf))
+               buf = NULL;
+ #endif
        }
      }
  
*** ../vim-8.2.4326/src/testdir/test_quickfix.vim       2022-02-01 
13:54:11.651302024 +0000
--- src/testdir/test_quickfix.vim       2022-02-08 14:59:45.809021812 +0000
***************
*** 5851,5855 ****
--- 5851,5880 ----
    delfunc R
  endfunc
  
+ " Another sequence of commands that caused all buffers to be wiped out
+ func Test_lopen_bwipe_all()
+   let lines =<< trim END
+     func R()
+       silent! tab lopen
+       e foo
+       silent! lfile
+     endfunc
+     cal R()
+     exe "norm \<C-W>\<C-V>0"
+     cal R()
+     bwipe
+ 
+     call writefile(['done'], 'Xresult')
+     qall!
+   END
+   call writefile(lines, 'Xscript')
+   if RunVim([], [], '-u NONE -n -X -Z -e -m -s -S Xscript')
+     call assert_equal(['done'], readfile('Xresult'))
+   endif
+ 
+   call delete('Xscript')
+   call delete('Xresult')
+ endfunc
+ 
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4326/src/version.c       2022-02-08 12:58:32.416043337 +0000
--- src/version.c       2022-02-08 14:38:02.987129022 +0000
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4327,
  /**/

-- 
If they don't keep on exercising their lips, he thought, their brains
start working.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// 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/20220208150745.530471C03A0%40moolenaar.net.

Raspunde prin e-mail lui