mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
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.
e3537aec2f
The test cannot be ported as-is because Nvim doesn't support "-Z"
command line argument. Just use only "--clean" instead.
This commit is contained in:
@@ -1284,8 +1284,10 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
|
|||||||
while (jumpidx != curwin->w_jumplistidx) {
|
while (jumpidx != curwin->w_jumplistidx) {
|
||||||
buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
|
buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum);
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
if (buf == curbuf || !buf->b_p_bl) {
|
// Skip current and unlisted bufs. Also skip a quickfix
|
||||||
buf = NULL; // skip current and unlisted bufs
|
// 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) {
|
} else if (buf->b_ml.ml_mfp == NULL) {
|
||||||
// skip unloaded buf, but may keep it for later
|
// skip unloaded buf, but may keep it for later
|
||||||
if (bp == NULL) {
|
if (bp == NULL) {
|
||||||
@@ -1323,7 +1325,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// in non-help buffer, try to skip help buffers, and vv
|
// 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
|
if (buf->b_ml.ml_mfp != NULL) { // found loaded buffer
|
||||||
break;
|
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
|
if (buf == NULL) { // No loaded buffer, find listed one
|
||||||
FOR_ALL_BUFFERS(buf2) {
|
FOR_ALL_BUFFERS(buf2) {
|
||||||
if (buf2->b_p_bl && buf2 != curbuf) {
|
if (buf2->b_p_bl && buf2 != curbuf && !bt_quickfix(buf2)) {
|
||||||
buf = buf2;
|
buf = buf2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1355,6 +1357,9 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
|
|||||||
} else {
|
} else {
|
||||||
buf = curbuf->b_prev;
|
buf = curbuf->b_prev;
|
||||||
}
|
}
|
||||||
|
if (bt_quickfix(buf)) {
|
||||||
|
buf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5505,5 +5505,30 @@ func Test_lopen_bwipe()
|
|||||||
delfunc R
|
delfunc R
|
||||||
endfunc
|
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([], [], '--clean -n -S Xscript')
|
||||||
|
call assert_equal(['done'], readfile('Xresult'))
|
||||||
|
endif
|
||||||
|
|
||||||
|
call delete('Xscript')
|
||||||
|
call delete('Xresult')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user