Skip to content

Commit e3537ae

Browse files
committed
patch 8.2.4327: may end up with no current buffer
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.
1 parent 51ab7c7 commit e3537ae

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

src/buffer.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,14 @@ do_buffer_ext(
14301430
buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
14311431
if (buf != NULL)
14321432
{
1433-
if (buf == curbuf || !buf->b_p_bl)
1434-
buf = NULL; // skip current and unlisted bufs
1433+
// Skip current and unlisted bufs. Also skip a quickfix
1434+
// buffer, it might be deleted soon.
1435+
if (buf == curbuf || !buf->b_p_bl
1436+
#if defined(FEAT_QUICKFIX)
1437+
|| bt_quickfix(buf)
1438+
#endif
1439+
)
1440+
buf = NULL;
14351441
else if (buf->b_ml.ml_mfp == NULL)
14361442
{
14371443
// skip unloaded buf, but may keep it for later
@@ -1467,7 +1473,11 @@ do_buffer_ext(
14671473
continue;
14681474
}
14691475
// in non-help buffer, try to skip help buffers, and vv
1470-
if (buf->b_help == curbuf->b_help && buf->b_p_bl)
1476+
if (buf->b_help == curbuf->b_help && buf->b_p_bl
1477+
#if defined(FEAT_QUICKFIX)
1478+
&& !bt_quickfix(buf)
1479+
#endif
1480+
)
14711481
{
14721482
if (buf->b_ml.ml_mfp != NULL) // found loaded buffer
14731483
break;
@@ -1485,7 +1495,11 @@ do_buffer_ext(
14851495
if (buf == NULL) // No loaded buffer, find listed one
14861496
{
14871497
FOR_ALL_BUFFERS(buf)
1488-
if (buf->b_p_bl && buf != curbuf)
1498+
if (buf->b_p_bl && buf != curbuf
1499+
#if defined(FEAT_QUICKFIX)
1500+
&& !bt_quickfix(buf)
1501+
#endif
1502+
)
14891503
break;
14901504
}
14911505
if (buf == NULL) // Still no buffer, just take one
@@ -1494,6 +1508,10 @@ do_buffer_ext(
14941508
buf = curbuf->b_next;
14951509
else
14961510
buf = curbuf->b_prev;
1511+
#if defined(FEAT_QUICKFIX)
1512+
if (bt_quickfix(buf))
1513+
buf = NULL;
1514+
#endif
14971515
}
14981516
}
14991517

src/testdir/test_quickfix.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5851,5 +5851,30 @@ func Test_lopen_bwipe()
58515851
delfunc R
58525852
endfunc
58535853

5854+
" Another sequence of commands that caused all buffers to be wiped out
5855+
func Test_lopen_bwipe_all()
5856+
let lines =<< trim END
5857+
func R()
5858+
silent! tab lopen
5859+
e foo
5860+
silent! lfile
5861+
endfunc
5862+
cal R()
5863+
exe "norm \<C-W>\<C-V>0"
5864+
cal R()
5865+
bwipe
5866+
5867+
call writefile(['done'], 'Xresult')
5868+
qall!
5869+
END
5870+
call writefile(lines, 'Xscript')
5871+
if RunVim([], [], '-u NONE -n -X -Z -e -m -s -S Xscript')
5872+
call assert_equal(['done'], readfile('Xresult'))
5873+
endif
5874+
5875+
call delete('Xscript')
5876+
call delete('Xresult')
5877+
endfunc
5878+
58545879

58555880
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ static char *(features[]) =
746746

747747
static int included_patches[] =
748748
{ /* Add new patch number below this line */
749+
/**/
750+
4327,
749751
/**/
750752
4326,
751753
/**/

0 commit comments

Comments
 (0)