aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c12
-rw-r--r--src/nvim/testdir/test_quickfix.vim7
2 files changed, 16 insertions, 3 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index e12a8bda2b..72fd035cbd 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -6020,12 +6020,18 @@ static int qf_winid(qf_info_T *qi)
}
/// Returns the number of the buffer displayed in the quickfix/location list
-/// window. If there is no buffer associated with the list, then returns 0.
+/// window. If there is no buffer associated with the list or the buffer is
+/// wiped out, then returns 0.
static int qf_getprop_qfbufnr(const qf_info_T *qi, dict_T *retdict)
FUNC_ATTR_NONNULL_ARG(2)
{
- return tv_dict_add_nr(retdict, S_LEN("qfbufnr"),
- (qi == NULL) ? 0 : qi->qf_bufnr);
+ int bufnum = 0;
+
+ if (qi != NULL && buflist_findnr(qi->qf_bufnr) != NULL) {
+ bufnum = qi->qf_bufnr;
+ }
+
+ return tv_dict_add_nr(retdict, S_LEN("qfbufnr"), bufnum);
}
/// Convert the keys in 'what' to quickfix list property flags.
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 48bafc4b7e..14d13049d9 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -4483,6 +4483,13 @@ func Xqfbuf_test(cchar)
call assert_equal(qfbnum, bufnr(''))
Xclose
+ " When quickfix buffer is wiped out, getqflist() should return 0
+ %bw!
+ Xexpr ""
+ Xopen
+ bw!
+ call assert_equal(0, g:Xgetlist({'qfbufnr': 0}).qfbufnr)
+
if a:cchar == 'l'
%bwipe
" For a location list, when both the file window and the location list