comparison src/quickfix.c @ 9540:64a791c53418 v7.4.2050

commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 16 18:24:56 2016 +0200 patch 7.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.
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Jul 2016 18:45:04 +0200
parents 26da1efa9e46
children ccbd2e604e59
comparison
equal deleted inserted replaced
9539:3bc6d72454fc 9540:64a791c53418
1579 */ 1579 */
1580 static char_u *qf_last_bufname = NULL; 1580 static char_u *qf_last_bufname = NULL;
1581 static bufref_T qf_last_bufref = {NULL, 0}; 1581 static bufref_T qf_last_bufref = {NULL, 0};
1582 1582
1583 /* 1583 /*
1584 * Get buffer number for file "dir.name". 1584 * Get buffer number for file "directory.fname".
1585 * Also sets the b_has_qf_entry flag. 1585 * Also sets the b_has_qf_entry flag.
1586 */ 1586 */
1587 static int 1587 static int
1588 qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname) 1588 qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
1589 { 1589 {
4107 { 4107 {
4108 col = 0; 4108 col = 0;
4109 while (vim_regexec_multi(&regmatch, curwin, buf, lnum, 4109 while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
4110 col, NULL) > 0) 4110 col, NULL) > 0)
4111 { 4111 {
4112 ; 4112 /* Pass the buffer number so that it gets used even for a
4113 * dummy buffer, unless duplicate_name is set, then the
4114 * buffer will be wiped out below. */
4113 if (qf_add_entry(qi, 4115 if (qf_add_entry(qi,
4114 NULL, /* dir */ 4116 NULL, /* dir */
4115 fname, 4117 fname,
4116 0, 4118 duplicate_name ? 0 : buf->b_fnum,
4117 ml_get_buf(buf, 4119 ml_get_buf(buf,
4118 regmatch.startpos[0].lnum + lnum, FALSE), 4120 regmatch.startpos[0].lnum + lnum, FALSE),
4119 regmatch.startpos[0].lnum + lnum, 4121 regmatch.startpos[0].lnum + lnum,
4120 regmatch.startpos[0].col + 1, 4122 regmatch.startpos[0].col + 1,
4121 FALSE, /* vis_col */ 4123 FALSE, /* vis_col */
4175 buf = NULL; 4177 buf = NULL;
4176 } 4178 }
4177 else if (buf != first_match_buf || (flags & VGR_NOJUMP)) 4179 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
4178 { 4180 {
4179 unload_dummy_buffer(buf, dirname_start); 4181 unload_dummy_buffer(buf, dirname_start);
4182 /* Keeping the buffer, remove the dummy flag. */
4183 buf->b_flags &= ~BF_DUMMY;
4180 buf = NULL; 4184 buf = NULL;
4181 } 4185 }
4182 } 4186 }
4183 4187
4184 if (buf != NULL) 4188 if (buf != NULL)
4185 { 4189 {
4190 /* Keeping the buffer, remove the dummy flag. */
4191 buf->b_flags &= ~BF_DUMMY;
4192
4186 /* If the buffer is still loaded we need to use the 4193 /* If the buffer is still loaded we need to use the
4187 * directory we jumped to below. */ 4194 * directory we jumped to below. */
4188 if (buf == first_match_buf 4195 if (buf == first_match_buf
4189 && target_dir == NULL 4196 && target_dir == NULL
4190 && STRCMP(dirname_start, dirname_now) != 0) 4197 && STRCMP(dirname_start, dirname_now) != 0)