aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/testdir/test_quickfix.vim12
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index b70e881d33..03f909f634 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -5255,8 +5255,14 @@ void ex_cbuffer(exarg_T *eap)
qf_list_changed(qi, qi->qf_curlist);
}
if (au_name != NULL) {
+ const buf_T *const curbuf_old = curbuf;
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name,
curbuf->b_fname, true, curbuf);
+ if (curbuf != curbuf_old) {
+ // Autocommands changed buffer, don't jump now, "qi" may
+ // be invalid.
+ res = 0;
+ }
}
if (res > 0 && (eap->cmdidx == CMD_cbuffer
|| eap->cmdidx == CMD_lbuffer)) {
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 12cd07a772..16fb86ea08 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3360,3 +3360,15 @@ func Test_vimgrep_autocmd()
call delete('Xtest2.txt')
call setqflist([], 'f')
endfunc
+
+func Test_lbuffer_with_bwipe()
+ new
+ new
+ augroup nasty
+ au * * bwipe
+ augroup END
+ lbuffer
+ augroup nasty
+ au!
+ augroup END
+endfunc