mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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.
015102e91e
This commit is contained in:
parent
1a06a39488
commit
827f2f9f6b
@ -1282,7 +1282,7 @@ void copy_loclist(win_T *from, win_T *to)
|
|||||||
to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
|
to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get buffer number for file "dir.name".
|
// Get buffer number for file "directory.fname".
|
||||||
// Also sets the b_has_qf_entry flag.
|
// Also sets the b_has_qf_entry flag.
|
||||||
static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
|
static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
|
||||||
{
|
{
|
||||||
@ -2123,7 +2123,7 @@ static void qf_msg(qf_info_T *qi, int which, char *lead)
|
|||||||
}
|
}
|
||||||
STRCAT(buf, title);
|
STRCAT(buf, title);
|
||||||
}
|
}
|
||||||
trunc_string(buf, buf, Columns - 1, IOSIZE);
|
trunc_string(buf, buf, (int)Columns - 1, IOSIZE);
|
||||||
msg(buf);
|
msg(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3484,10 +3484,13 @@ void ex_vimgrep(exarg_T *eap)
|
|||||||
col = 0;
|
col = 0;
|
||||||
while (vim_regexec_multi(®match, curwin, buf, lnum,
|
while (vim_regexec_multi(®match, curwin, buf, lnum,
|
||||||
col, NULL) > 0) {
|
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,
|
if (qf_add_entry(qi,
|
||||||
NULL, // dir
|
NULL, // dir
|
||||||
fname,
|
fname,
|
||||||
0,
|
duplicate_name ? 0 : buf->b_fnum,
|
||||||
ml_get_buf(buf,
|
ml_get_buf(buf,
|
||||||
regmatch.startpos[0].lnum + lnum, false),
|
regmatch.startpos[0].lnum + lnum, false),
|
||||||
regmatch.startpos[0].lnum + lnum,
|
regmatch.startpos[0].lnum + lnum,
|
||||||
@ -3541,17 +3544,23 @@ void ex_vimgrep(exarg_T *eap)
|
|||||||
buf = NULL;
|
buf = NULL;
|
||||||
} else if (buf != first_match_buf || (flags & VGR_NOJUMP)) {
|
} else if (buf != first_match_buf || (flags & VGR_NOJUMP)) {
|
||||||
unload_dummy_buffer(buf, dirname_start);
|
unload_dummy_buffer(buf, dirname_start);
|
||||||
|
// Keeping the buffer, remove the dummy flag.
|
||||||
|
buf->b_flags &= ~BF_DUMMY;
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
/* If the buffer is still loaded we need to use the
|
// Keeping the buffer, remove the dummy flag.
|
||||||
* directory we jumped to below. */
|
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
|
if (buf == first_match_buf
|
||||||
&& target_dir == NULL
|
&& target_dir == NULL
|
||||||
&& STRCMP(dirname_start, dirname_now) != 0)
|
&& STRCMP(dirname_start, dirname_now) != 0) {
|
||||||
target_dir = vim_strsave(dirname_now);
|
target_dir = vim_strsave(dirname_now);
|
||||||
|
}
|
||||||
|
|
||||||
/* The buffer is still loaded, the Filetype autocommands
|
/* The buffer is still loaded, the Filetype autocommands
|
||||||
* need to be done now, in that buffer. And the modelines
|
* need to be done now, in that buffer. And the modelines
|
||||||
|
@ -1444,3 +1444,18 @@ func Test_history()
|
|||||||
call HistoryTest('c')
|
call HistoryTest('c')
|
||||||
call HistoryTest('l')
|
call HistoryTest('l')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_duplicate_buf()
|
||||||
|
" make sure we can get the highest buffer number
|
||||||
|
edit DoesNotExist
|
||||||
|
edit DoesNotExist2
|
||||||
|
let last_buffer = bufnr("$")
|
||||||
|
|
||||||
|
" make sure only one buffer is created
|
||||||
|
call writefile(['this one', 'that one'], 'Xgrepthis')
|
||||||
|
vimgrep one Xgrepthis
|
||||||
|
vimgrep one Xgrepthis
|
||||||
|
call assert_equal(last_buffer + 1, bufnr("$"))
|
||||||
|
|
||||||
|
call delete('Xgrepthis')
|
||||||
|
endfunc
|
||||||
|
@ -390,7 +390,7 @@ static int included_patches[] = {
|
|||||||
// 2053 NA
|
// 2053 NA
|
||||||
// 2052 NA
|
// 2052 NA
|
||||||
// 2051,
|
// 2051,
|
||||||
// 2050,
|
2050,
|
||||||
2049,
|
2049,
|
||||||
// 2048 NA
|
// 2048 NA
|
||||||
// 2047,
|
// 2047,
|
||||||
|
Loading…
Reference in New Issue
Block a user