aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-24 12:39:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-26 09:51:59 +0800
commitd8b4f3e3b83d5a0fd5d844da34da23c88dc9c4c5 (patch)
tree006530ae92e70ebfa98a8723999f1cbd6d800430 /src/nvim/buffer.c
parent19bbc43947a75b0279f9697f5830a238af337c5b (diff)
downloadrneovim-d8b4f3e3b83d5a0fd5d844da34da23c88dc9c4c5.tar.gz
rneovim-d8b4f3e3b83d5a0fd5d844da34da23c88dc9c4c5.tar.bz2
rneovim-d8b4f3e3b83d5a0fd5d844da34da23c88dc9c4c5.zip
vim-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. https://github.com/vim/vim/commit/e3537aec2f8d6470010547af28dcbd83d41461b8 The test cannot be ported as-is because Nvim doesn't support "-Z" command line argument. Just use only "--clean" instead.
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 8d042525d3..4ca752e747 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1284,8 +1284,10 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
while (jumpidx != curwin->w_jumplistidx) {
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 || bt_quickfix(buf)) {
+ buf = NULL;
} else if (buf->b_ml.ml_mfp == NULL) {
// skip unloaded buf, but may keep it for later
if (bp == NULL) {
@@ -1323,7 +1325,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
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 && !bt_quickfix(buf)) {
if (buf->b_ml.ml_mfp != NULL) { // found loaded buffer
break;
}
@@ -1343,7 +1345,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
if (buf == NULL) { // No loaded buffer, find listed one
FOR_ALL_BUFFERS(buf2) {
- if (buf2->b_p_bl && buf2 != curbuf) {
+ if (buf2->b_p_bl && buf2 != curbuf && !bt_quickfix(buf2)) {
buf = buf2;
break;
}
@@ -1355,6 +1357,9 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
} else {
buf = curbuf->b_prev;
}
+ if (bt_quickfix(buf)) {
+ buf = NULL;
+ }
}
}