vim-patch:7.4.689

Problem:    On MS-Windows, when 'autochdir' is set, diff mode with files in
            different directories does not work. (Axel Bender)
Solution:   Remember the current directory and use it where needed. (Christian
            Brabandt)

d87c36ea5e

---

see: "autochdir + encoding=utf8 messes up diff"
     https://groups.google.com/d/msg/vim_dev/QrE4Y2LMJR8/uxigns5KGxYJ
This commit is contained in:
watiko
2016-02-04 03:47:55 +09:00
parent d9cada146f
commit 1ecbfd19db
2 changed files with 26 additions and 18 deletions

View File

@@ -219,9 +219,10 @@ int main(int argc, char **argv)
{ {
argv0 = (char *)path_tail((char_u *)argv[0]); argv0 = (char *)path_tail((char_u *)argv[0]);
char_u *fname = NULL; /* file name from command line */ char_u *fname = NULL; // file name from command line
mparm_T params; /* various parameters passed between mparm_T params; // various parameters passed between
* main() and other functions. */ // main() and other functions.
char_u *cwd = NULL; // current workding dir on startup
time_init(); time_init();
/* Many variables are in "params" so that we can pass them to invoked /* Many variables are in "params" so that we can pass them to invoked
@@ -461,11 +462,10 @@ int main(int argc, char **argv)
TIME_MSG("jump to first error"); TIME_MSG("jump to first error");
} }
/* // If opened more than one window, start editing files in the other
* If opened more than one window, start editing files in the other // windows.
* windows. edit_buffers(&params, cwd);
*/ xfree(cwd);
edit_buffers(&params);
if (params.diff_mode) { if (params.diff_mode) {
/* set options in each window for "nvim -d". */ /* set options in each window for "nvim -d". */
@@ -1182,12 +1182,19 @@ static char_u *get_fname(mparm_T *parmp)
* Expand wildcards in file names. * Expand wildcards in file names.
*/ */
if (!parmp->literal) { if (!parmp->literal) {
/* Temporarily add '(' and ')' to 'isfname'. These are valid cwd = xmalloc(MAXPATHL);
* filename characters but are excluded from 'isfname' to make if (cwd != NULL) {
* "gf" work on a file name in parenthesis (e.g.: see vim.h). */ os_dirname(cwd, MAXPATHL);
}
// Temporarily add '(' and ')' to 'isfname'. These are valid
// filename characters but are excluded from 'isfname' to make
// "gf" work on a file name in parenthesis (e.g.: see vim.h).
do_cmdline_cmd(":set isf+=(,)"); do_cmdline_cmd(":set isf+=(,)");
alist_expand(NULL, 0); alist_expand(NULL, 0);
do_cmdline_cmd(":set isf&"); do_cmdline_cmd(":set isf&");
if (cwd != NULL) {
os_chdir((char *)cwd);
}
} }
#endif #endif
return alist_name(&GARGLIST[0]); return alist_name(&GARGLIST[0]);
@@ -1417,11 +1424,9 @@ static void create_windows(mparm_T *parmp)
} }
} }
/* /// If opened more than one window, start editing files in the other
* If opened more than one window, start editing files in the other /// windows. make_windows() has already opened the windows.
* windows. make_windows() has already opened the windows. static void edit_buffers(mparm_T *parmp, char_u *cwd)
*/
static void edit_buffers(mparm_T *parmp)
{ {
int arg_idx; /* index in argument list */ int arg_idx; /* index in argument list */
int i; int i;
@@ -1442,7 +1447,10 @@ static void edit_buffers(mparm_T *parmp)
arg_idx = 1; arg_idx = 1;
for (i = 1; i < parmp->window_count; ++i) { for (i = 1; i < parmp->window_count; ++i) {
/* When w_arg_idx is -1 remove the window (see create_windows()). */ if (cwd != NULL) {
os_chdir((char *)cwd);
}
// When w_arg_idx is -1 remove the window (see create_windows()).
if (curwin->w_arg_idx == -1) { if (curwin->w_arg_idx == -1) {
++arg_idx; ++arg_idx;
win_close(curwin, TRUE); win_close(curwin, TRUE);

View File

@@ -599,7 +599,7 @@ static int included_patches[] = {
// 692 NA // 692 NA
// 691 NA // 691 NA
690, 690,
// 689, 689,
688, 688,
// 687 NA // 687 NA
686, 686,