summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-08 20:03:31 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-08 20:03:31 +0000
commit78a61068cf2c83e611d954a0fb413a09ad59dc07 (patch)
treebc57cdc4b0fdf24746f4e2e6bb91a3dc609d29a0
parent2172bff36417ddd90653531edc65897411c83b3f (diff)
downloadvim-git-78a61068cf2c83e611d954a0fb413a09ad59dc07.tar.gz
patch 8.2.3759: quickfix buffer becomes hidden while still in a windowv8.2.3759
Problem: Quickfix buffer becomes hidden while still in a window. Solution: Check if the closed window is the last window showing the quickfix buffer. (Yegappan Lakshmanan, closes #9303, closes #9300)
-rw-r--r--src/quickfix.c16
-rw-r--r--src/testdir/test_quickfix.vim36
-rw-r--r--src/version.c2
-rw-r--r--src/window.c6
4 files changed, 50 insertions, 10 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index d7c0a88a6..1e25edb7e 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2818,7 +2818,7 @@ qf_get_entry(
}
/*
- * Find a window displaying a Vim help file.
+ * Find a window displaying a Vim help file in the current tab page.
*/
static win_T *
qf_find_help_win(void)
@@ -2893,8 +2893,8 @@ jump_to_help_window(qf_info_T *qi, int newwin, int *opened_window)
}
/*
- * Find a non-quickfix window in the current tabpage using the given location
- * list stack.
+ * Find a non-quickfix window using the given location list stack in the
+ * current tabpage.
* Returns NULL if a matching window is not found.
*/
static win_T *
@@ -2910,7 +2910,7 @@ qf_find_win_with_loclist(qf_info_T *ll)
}
/*
- * Find a window containing a normal buffer
+ * Find a window containing a normal buffer in the current tab page.
*/
static win_T *
qf_find_win_with_normal_buf(void)
@@ -2981,7 +2981,7 @@ qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum, qf_info_T *ll_ref)
if (win == NULL)
{
- // Find the window showing the selected file
+ // Find the window showing the selected file in the current tab page.
FOR_ALL_WINDOWS(win)
if (win->w_buffer->b_fnum == qf_fnum)
break;
@@ -4394,8 +4394,8 @@ is_qf_win(win_T *win, qf_info_T *qi)
}
/*
- * Find a window displaying the quickfix/location stack 'qi'
- * Only searches in the current tabpage.
+ * Find a window displaying the quickfix/location stack 'qi' in the current tab
+ * page.
*/
static win_T *
qf_find_win(qf_info_T *qi)
@@ -4410,7 +4410,7 @@ qf_find_win(qf_info_T *qi)
/*
* Find a quickfix buffer.
- * Searches in windows opened in all the tabs.
+ * Searches in windows opened in all the tab pages.
*/
static buf_T *
qf_find_buf(qf_info_T *qi)
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 24526bd77..b242ac5fa 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -5636,4 +5636,40 @@ fun Test_vimgrep_nomatch()
cclose
endfunc
+" Test for opening the quickfix window in two tab pages and then closing one
+" of the quickfix windows. This should not make the quickfix buffer unlisted.
+" (github issue #9300).
+func Test_two_qf_windows()
+ cexpr "F1:1:line1"
+ copen
+ tabnew
+ copen
+ call assert_true(&buflisted)
+ cclose
+ tabfirst
+ call assert_true(&buflisted)
+ let bnum = bufnr()
+ cclose
+ " if all the quickfix windows are closed, then buffer should be unlisted.
+ call assert_false(buflisted(bnum))
+ %bw!
+
+ " Repeat the test for a location list
+ lexpr "F2:2:line2"
+ lopen
+ let bnum = bufnr()
+ tabnew
+ exe "buffer" bnum
+ tabfirst
+ lclose
+ tablast
+ call assert_true(buflisted(bnum))
+ tabclose
+ lopen
+ call assert_true(buflisted(bnum))
+ lclose
+ call assert_false(buflisted(bnum))
+ %bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 6d5817538..13b6a0cf6 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 */
/**/
+ 3759,
+/**/
3758,
/**/
3757,
diff --git a/src/window.c b/src/window.c
index 4050ed04d..47fb81597 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2433,8 +2433,10 @@ win_close_buffer(win_T *win, int action, int abort_if_last)
#endif
#ifdef FEAT_QUICKFIX
- // When the quickfix/location list window is closed, unlist the buffer.
- if (win->w_buffer != NULL && bt_quickfix(win->w_buffer))
+ // When a quickfix/location list window is closed and the buffer is
+ // displayed in only one window, then unlist the buffer.
+ if (win->w_buffer != NULL && bt_quickfix(win->w_buffer)
+ && win->w_buffer->b_nwindows == 1)
win->w_buffer->b_p_bl = FALSE;
#endif