0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

updated for version 7.1-126

This commit is contained in:
Bram Moolenaar
2007-09-30 12:02:55 +00:00
parent 78ab331e0d
commit d089d9b33a
9 changed files with 81 additions and 36 deletions

View File

@@ -2972,6 +2972,7 @@ ex_vimgrep(eap)
regmmatch_T regmatch;
int fcount;
char_u **fnames;
char_u *fname;
char_u *s;
char_u *p;
int fi;
@@ -2995,6 +2996,9 @@ ex_vimgrep(eap)
int flags = 0;
colnr_T col;
long tomatch;
char_u dirname_start[MAXPATHL];
char_u dirname_now[MAXPATHL];
char_u *target_dir = NULL;
switch (eap->cmdidx)
{
@@ -3069,17 +3073,23 @@ ex_vimgrep(eap)
goto theend;
}
/* Remember the current directory, because a BufRead autocommand that does
* ":lcd %:p:h" changes the meaning of short path names. */
mch_dirname(dirname_start, MAXPATHL);
seconds = (time_t)0;
for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
{
fname = shorten_fname1(fnames[fi]);
if (time(NULL) > seconds)
{
/* Display the file name every second or so. */
/* Display the file name every second or so, show the user we are
* working on it. */
seconds = time(NULL);
msg_start();
p = msg_strtrunc(fnames[fi], TRUE);
p = msg_strtrunc(fname, TRUE);
if (p == NULL)
msg_outtrans(fnames[fi]);
msg_outtrans(fname);
else
{
msg_outtrans(p);
@@ -3111,7 +3121,19 @@ ex_vimgrep(eap)
/* Load file into a buffer, so that 'fileencoding' is detected,
* autocommands applied, etc. */
buf = load_dummy_buffer(fnames[fi]);
buf = load_dummy_buffer(fname);
/* When autocommands changed directory: go back. We assume it was
* ":lcd %:p:h". */
mch_dirname(dirname_now, MAXPATHL);
if (STRCMP(dirname_start, dirname_now) != 0)
{
exarg_T ea;
ea.arg = dirname_start;
ea.cmdidx = CMD_lcd;
ex_cd(&ea);
}
p_mls = save_mls;
#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
@@ -3125,7 +3147,7 @@ ex_vimgrep(eap)
if (buf == NULL)
{
if (!got_int)
smsg((char_u *)_("Cannot open file \"%s\""), fnames[fi]);
smsg((char_u *)_("Cannot open file \"%s\""), fname);
}
else
{
@@ -3139,9 +3161,10 @@ ex_vimgrep(eap)
while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
col) > 0)
{
;
if (qf_add_entry(qi, &prevp,
NULL, /* dir */
fnames[fi],
fname,
0,
ml_get_buf(buf,
regmatch.startpos[0].lnum + lnum, FALSE),
@@ -3209,6 +3232,13 @@ ex_vimgrep(eap)
if (buf != NULL)
{
/* If the buffer is still loaded we need to use the
* directory we jumped to below. */
if (buf == first_match_buf
&& target_dir == NULL
&& STRCMP(dirname_start, dirname_now) != 0)
target_dir = vim_strsave(dirname_now);
/* The buffer is still loaded, the Filetype autocommands
* need to be done now, in that buffer. And the modelines
* need to be done (again). But not the window-local
@@ -3252,6 +3282,16 @@ ex_vimgrep(eap)
/* If we jumped to another buffer redrawing will already be
* taken care of. */
redraw_for_dummy = FALSE;
/* Jump to the directory used after loading the buffer. */
if (curbuf == first_match_buf && target_dir != NULL)
{
exarg_T ea;
ea.arg = target_dir;
ea.cmdidx = CMD_lcd;
ex_cd(&ea);
}
}
}
else
@@ -3269,6 +3309,7 @@ ex_vimgrep(eap)
}
theend:
vim_free(target_dir);
vim_free(regmatch.regprog);
}