summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-09 09:27:06 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-09 09:27:06 +0000
commit56150da6879a96db1c84c7ec4ceedeb84969f606 (patch)
tree165896a3fa2c84c3517c8aad24a74ddd50c92f01
parenta48d4e44a24191f5495e17d7616771c20ae3e3c1 (diff)
downloadvim-git-56150da6879a96db1c84c7ec4ceedeb84969f606.tar.gz
patch 8.2.3762: if quickfix buffer is wiped out getqflist() still returns itv8.2.3762
Problem: If the quickfix buffer is wiped out getqflist() still returns its number. Solution: Use zero if the buffer is no longer present. (Yegappan Lakshmanan, closes #9306)
-rw-r--r--src/quickfix.c11
-rw-r--r--src/testdir/test_quickfix.vim7
-rw-r--r--src/version.c2
3 files changed, 17 insertions, 3 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 1e25edb7e..c7abc8ec4 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -6793,13 +6793,18 @@ 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(qf_info_T *qi, dict_T *retdict)
{
- return dict_add_number(retdict, "qfbufnr",
- (qi == NULL) ? 0 : qi->qf_bufnr);
+ int bufnum = 0;
+
+ if (qi != NULL && buflist_findnr(qi->qf_bufnr) != NULL)
+ bufnum = qi->qf_bufnr;
+
+ return dict_add_number(retdict, "qfbufnr", bufnum);
}
/*
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index b242ac5fa..940b4d627 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -4626,6 +4626,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
diff --git a/src/version.c b/src/version.c
index 086465526..a8f2b36a1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3762,
+/**/
3761,
/**/
3760,