Mercurial > vim
comparison src/main.c @ 6731:7d40186f767a v7.4.689
updated for version 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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 03 Apr 2015 14:56:49 +0200 |
parents | b225e8fed8cc |
children | f6021786b775 |
comparison
equal
deleted
inserted
replaced
6730:f7b237bd6606 | 6731:7d40186f767a |
---|---|
108 static void command_line_scan __ARGS((mparm_T *parmp)); | 108 static void command_line_scan __ARGS((mparm_T *parmp)); |
109 static void check_tty __ARGS((mparm_T *parmp)); | 109 static void check_tty __ARGS((mparm_T *parmp)); |
110 static void read_stdin __ARGS((void)); | 110 static void read_stdin __ARGS((void)); |
111 static void create_windows __ARGS((mparm_T *parmp)); | 111 static void create_windows __ARGS((mparm_T *parmp)); |
112 # ifdef FEAT_WINDOWS | 112 # ifdef FEAT_WINDOWS |
113 static void edit_buffers __ARGS((mparm_T *parmp)); | 113 static void edit_buffers __ARGS((mparm_T *parmp, char_u *cwd)); |
114 # endif | 114 # endif |
115 static void exe_pre_commands __ARGS((mparm_T *parmp)); | 115 static void exe_pre_commands __ARGS((mparm_T *parmp)); |
116 static void exe_commands __ARGS((mparm_T *parmp)); | 116 static void exe_commands __ARGS((mparm_T *parmp)); |
117 static void source_startup_scripts __ARGS((mparm_T *parmp)); | 117 static void source_startup_scripts __ARGS((mparm_T *parmp)); |
118 static void main_start_gui __ARGS((void)); | 118 static void main_start_gui __ARGS((void)); |
166 char **argv; | 166 char **argv; |
167 { | 167 { |
168 char_u *fname = NULL; /* file name from command line */ | 168 char_u *fname = NULL; /* file name from command line */ |
169 mparm_T params; /* various parameters passed between | 169 mparm_T params; /* various parameters passed between |
170 * main() and other functions. */ | 170 * main() and other functions. */ |
171 char_u *cwd = NULL; /* current workding dir on startup */ | |
171 #ifdef STARTUPTIME | 172 #ifdef STARTUPTIME |
172 int i; | 173 int i; |
173 #endif | 174 #endif |
174 | 175 |
175 /* | 176 /* |
402 /* | 403 /* |
403 * Expand wildcards in file names. | 404 * Expand wildcards in file names. |
404 */ | 405 */ |
405 if (!params.literal) | 406 if (!params.literal) |
406 { | 407 { |
408 cwd = alloc(MAXPATHL); | |
409 if (cwd != NULL) | |
410 mch_dirname(cwd, MAXPATHL); | |
407 /* Temporarily add '(' and ')' to 'isfname'. These are valid | 411 /* Temporarily add '(' and ')' to 'isfname'. These are valid |
408 * filename characters but are excluded from 'isfname' to make | 412 * filename characters but are excluded from 'isfname' to make |
409 * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ | 413 * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ |
410 do_cmdline_cmd((char_u *)":set isf+=(,)"); | 414 do_cmdline_cmd((char_u *)":set isf+=(,)"); |
411 alist_expand(NULL, 0); | 415 alist_expand(NULL, 0); |
412 do_cmdline_cmd((char_u *)":set isf&"); | 416 do_cmdline_cmd((char_u *)":set isf&"); |
417 if (cwd != NULL) | |
418 mch_chdir((char *)cwd); | |
413 } | 419 } |
414 #endif | 420 #endif |
415 fname = alist_name(&GARGLIST[0]); | 421 fname = alist_name(&GARGLIST[0]); |
416 } | 422 } |
417 | 423 |
433 * been invoked from explorer, so change to the file's directory. | 439 * been invoked from explorer, so change to the file's directory. |
434 * Hint: to avoid this when typing a command use a forward slash. | 440 * Hint: to avoid this when typing a command use a forward slash. |
435 * If the cd fails, it doesn't matter. | 441 * If the cd fails, it doesn't matter. |
436 */ | 442 */ |
437 (void)vim_chdirfile(fname); | 443 (void)vim_chdirfile(fname); |
444 if (cwd != NULL) | |
445 mch_dirnamem(cwd, MAXPATHL); | |
438 } | 446 } |
439 #endif | 447 #endif |
440 TIME_MSG("expanding arguments"); | 448 TIME_MSG("expanding arguments"); |
441 | 449 |
442 #ifdef FEAT_DIFF | 450 #ifdef FEAT_DIFF |
486 else | 494 else |
487 { | 495 { |
488 expand_env((char_u *)"$HOME", NameBuff, MAXPATHL); | 496 expand_env((char_u *)"$HOME", NameBuff, MAXPATHL); |
489 vim_chdir(NameBuff); | 497 vim_chdir(NameBuff); |
490 } | 498 } |
499 if (cwd != NULL) | |
500 mch_dirname(cwd, MAXPATHL); | |
491 } | 501 } |
492 } | 502 } |
493 #endif | 503 #endif |
494 | 504 |
495 /* | 505 /* |
898 #ifdef FEAT_WINDOWS | 908 #ifdef FEAT_WINDOWS |
899 /* | 909 /* |
900 * If opened more than one window, start editing files in the other | 910 * If opened more than one window, start editing files in the other |
901 * windows. | 911 * windows. |
902 */ | 912 */ |
903 edit_buffers(¶ms); | 913 edit_buffers(¶ms, cwd); |
904 #endif | 914 #endif |
915 vim_free(cwd); | |
905 | 916 |
906 #ifdef FEAT_DIFF | 917 #ifdef FEAT_DIFF |
907 if (params.diff_mode) | 918 if (params.diff_mode) |
908 { | 919 { |
909 win_T *wp; | 920 win_T *wp; |
2728 /* | 2739 /* |
2729 * If opened more than one window, start editing files in the other | 2740 * If opened more than one window, start editing files in the other |
2730 * windows. make_windows() has already opened the windows. | 2741 * windows. make_windows() has already opened the windows. |
2731 */ | 2742 */ |
2732 static void | 2743 static void |
2733 edit_buffers(parmp) | 2744 edit_buffers(parmp, cwd) |
2734 mparm_T *parmp; | 2745 mparm_T *parmp; |
2746 char_u *cwd; /* current working dir */ | |
2735 { | 2747 { |
2736 int arg_idx; /* index in argument list */ | 2748 int arg_idx; /* index in argument list */ |
2737 int i; | 2749 int i; |
2738 int advance = TRUE; | 2750 int advance = TRUE; |
2739 win_T *win; | 2751 win_T *win; |
2754 } | 2766 } |
2755 | 2767 |
2756 arg_idx = 1; | 2768 arg_idx = 1; |
2757 for (i = 1; i < parmp->window_count; ++i) | 2769 for (i = 1; i < parmp->window_count; ++i) |
2758 { | 2770 { |
2771 if (cwd != NULL) | |
2772 mch_chdir((char *)cwd); | |
2759 /* When w_arg_idx is -1 remove the window (see create_windows()). */ | 2773 /* When w_arg_idx is -1 remove the window (see create_windows()). */ |
2760 if (curwin->w_arg_idx == -1) | 2774 if (curwin->w_arg_idx == -1) |
2761 { | 2775 { |
2762 ++arg_idx; | 2776 ++arg_idx; |
2763 win_close(curwin, TRUE); | 2777 win_close(curwin, TRUE); |