Mercurial > vim
diff src/buffer.c @ 27601:cb46dd386990 v8.2.4327
patch 8.2.4327: may end up with no current buffer
Commit: https://github.com/vim/vim/commit/e3537aec2f8d6470010547af28dcbd83d41461b8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 8 15:05:20 2022 +0000
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Feb 2022 16:15:03 +0100 |
parents | b8a5de86e9d1 |
children | ba47c7d07ce6 |
line wrap: on
line diff
--- a/src/buffer.c +++ b/src/buffer.c @@ -1430,8 +1430,14 @@ do_buffer_ext( 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 + // 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,7 +1473,11 @@ do_buffer_ext( 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_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,7 +1495,11 @@ do_buffer_ext( if (buf == NULL) // No loaded buffer, find listed one { FOR_ALL_BUFFERS(buf) - if (buf->b_p_bl && buf != curbuf) + 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,6 +1508,10 @@ do_buffer_ext( buf = curbuf->b_next; else buf = curbuf->b_prev; +#if defined(FEAT_QUICKFIX) + if (bt_quickfix(buf)) + buf = NULL; +#endif } }