On Feb 1, 4:29 pm, Ben Fritz <[email protected]> wrote: > Trying to grep an entire project tree fails with autochdir set: > > gvim -N -u NONE -i NONE C:/path/to/project/dir/relative/path/in/ > project/somedir/file.c > set autochdir > cd C:/path/to/project/dir > vimgrep /pattern/j relative/path/in/project/**/*.[ch] > > Gives: > C:\path\to\project\dir > "relative\path\in\project\somedir\file.c" [New DIRECTORY] > C:\path\to\project\dir > "relative\path\in\project\somedir\file2.c" [New DIRECTORY] > C:\path\to\project\dir > "relative\path\in\project\somedir\file3.c" [New DIRECTORY] > ... > E480: No match: pattern > > But without the set autochdir, the vimgrep correctly finds all > occurrences of pattern in the project. > > I'm about 95% sure this worked at some point in the past, because this > is how I've done similar searches before. >
Actually, it turns out, the issue has been around a long time. I went back to 7.2.160 and the issue exists there as well. This patch fixes it, but probably a better way would be to insert the directory restore code in each "dummy_buffer" function. Is there a way to detect whether 'cd' or 'lcd' was used, as well? It seems that assuming the user used :lcd is an assumption which might bite somebody at some point. Based off v7.3.393. # HG changeset patch # User Ben Fritz <[email protected]> # Date 1328238920 21600 # Branch 2html-dev # Node ID 102067eb613dc58082919c594e225411c5c3467d # Parent 11151971549e24bab14c759849116f1c60292d90 fix vimgrep when 'acd' is set diff -r 11151971549e -r 102067eb613d src/quickfix.c --- a/src/quickfix.c Mon Jan 09 22:19:10 2012 -0600 +++ b/src/quickfix.c Thu Feb 02 21:15:20 2012 -0600 @@ -3211,15 +3211,22 @@ * autocommands applied, etc. */ buf = load_dummy_buffer(fname); - /* When autocommands changed directory: go back. We assume it was - * ":lcd %:p:h". */ + /* When autocommands or 'autochdir' option 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; + if (p_acd) + { + ea.cmdidx = CMD_cd; + } + else + { + ea.cmdidx = CMD_lcd; + } ex_cd(&ea); } @@ -3294,6 +3301,25 @@ * with the same name. */ wipe_dummy_buffer(buf); buf = NULL; + + /* When autocommands or 'autochdir' option 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; + if (p_acd) + { + ea.cmdidx = CMD_cd; + } + else + { + ea.cmdidx = CMD_lcd; + } + ex_cd(&ea); + } } else if (!cmdmod.hide || buf->b_p_bh[0] == 'u' /* "unload" */ @@ -3310,11 +3336,52 @@ { wipe_dummy_buffer(buf); buf = NULL; + + /* When autocommands or 'autochdir' option 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; + if (p_acd) + { + ea.cmdidx = CMD_cd; + } + else + { + ea.cmdidx = CMD_lcd; + } + ex_cd(&ea); + } } else if (buf != first_match_buf || (flags & VGR_NOJUMP)) { unload_dummy_buffer(buf); buf = NULL; + + /* When autocommands or 'autochdir' option 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; + if (p_acd) + { + ea.cmdidx = CMD_cd; + } + else + { + ea.cmdidx = CMD_lcd; + } + ex_cd(&ea); + } + } } -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
