summaryrefslogtreecommitdiff
path: root/src/quickfix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-16 18:24:56 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-16 18:24:56 +0200
commit015102e91e978a0bb42a14461c132a85e8f7e1ea (patch)
treef00c9b4bec0c5debda549ab786c5ccc7a5d73dbf /src/quickfix.c
parentf6acffbe83e622542d9fdf3066f51933e46e4954 (diff)
downloadvim-git-015102e91e978a0bb42a14461c132a85e8f7e1ea.tar.gz
patch 7.4.2050v7.4.2050
Problem: When using ":vimgrep" may end up with duplicate buffers. Solution: When adding an error list entry pass the buffer number if possible.
Diffstat (limited to 'src/quickfix.c')
-rw-r--r--src/quickfix.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 1fb47a009..1145896e1 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1581,7 +1581,7 @@ static char_u *qf_last_bufname = NULL;
static bufref_T qf_last_bufref = {NULL, 0};
/*
- * Get buffer number for file "dir.name".
+ * Get buffer number for file "directory.fname".
* Also sets the b_has_qf_entry flag.
*/
static int
@@ -4109,11 +4109,13 @@ ex_vimgrep(exarg_T *eap)
while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
col, NULL) > 0)
{
- ;
+ /* Pass the buffer number so that it gets used even for a
+ * dummy buffer, unless duplicate_name is set, then the
+ * buffer will be wiped out below. */
if (qf_add_entry(qi,
NULL, /* dir */
fname,
- 0,
+ duplicate_name ? 0 : buf->b_fnum,
ml_get_buf(buf,
regmatch.startpos[0].lnum + lnum, FALSE),
regmatch.startpos[0].lnum + lnum,
@@ -4177,12 +4179,17 @@ ex_vimgrep(exarg_T *eap)
else if (buf != first_match_buf || (flags & VGR_NOJUMP))
{
unload_dummy_buffer(buf, dirname_start);
+ /* Keeping the buffer, remove the dummy flag. */
+ buf->b_flags &= ~BF_DUMMY;
buf = NULL;
}
}
if (buf != NULL)
{
+ /* Keeping the buffer, remove the dummy flag. */
+ buf->b_flags &= ~BF_DUMMY;
+
/* If the buffer is still loaded we need to use the
* directory we jumped to below. */
if (buf == first_match_buf