]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3762: if quickfix buffer is wiped out getqflist() still returns it v8.2.3762
authorYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 9 Dec 2021 09:27:06 +0000 (09:27 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Dec 2021 09:27:06 +0000 (09:27 +0000)
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)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 1e25edb7e55a31cfd6c741b1fc3a27d6017a3c28..c7abc8ec4a8e0c16d5d1d064c7e163d212d1d366 100644 (file)
@@ -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);
 }
 
 /*
index b242ac5fa2da9cf29ba80c718535f6875436442c..940b4d6274ae85d43823cf0e0c908a33afc55da8 100644 (file)
@@ -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
index 086465526bfd1ac06fa4d9009e8b4f0dc13957e0..a8f2b36a149e9b4e8e74391182a00a88535f4ec4 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3762,
 /**/
     3761,
 /**/