Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.689
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

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)
Files:	    src/main.c


*** ../vim-7.4.688/src/main.c	2015-03-24 16:48:16.969934944 +0100
--- src/main.c	2015-04-03 14:52:48.011422200 +0200
***************
*** 110,116 ****
  static void read_stdin __ARGS((void));
  static void create_windows __ARGS((mparm_T *parmp));
  # ifdef FEAT_WINDOWS
! static void edit_buffers __ARGS((mparm_T *parmp));
  # endif
  static void exe_pre_commands __ARGS((mparm_T *parmp));
  static void exe_commands __ARGS((mparm_T *parmp));
--- 110,116 ----
  static void read_stdin __ARGS((void));
  static void create_windows __ARGS((mparm_T *parmp));
  # ifdef FEAT_WINDOWS
! static void edit_buffers __ARGS((mparm_T *parmp, char_u *cwd));
  # endif
  static void exe_pre_commands __ARGS((mparm_T *parmp));
  static void exe_commands __ARGS((mparm_T *parmp));
***************
*** 168,173 ****
--- 168,174 ----
      char_u	*fname = NULL;		/* file name from command line */
      mparm_T	params;			/* various parameters passed between
  					 * main() and other functions. */
+     char_u	*cwd = NULL;		/* current workding dir on startup */
  #ifdef STARTUPTIME
      int		i;
  #endif
***************
*** 404,415 ****
--- 405,421 ----
  	 */
  	if (!params.literal)
  	{
+ 	    cwd = alloc(MAXPATHL);
+ 	    if (cwd != NULL)
+ 		mch_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((char_u *)":set isf+=(,)");
  	    alist_expand(NULL, 0);
  	    do_cmdline_cmd((char_u *)":set isf&");
+ 	    if (cwd != NULL)
+ 		mch_chdir((char *)cwd);
  	}
  #endif
  	fname = alist_name(&GARGLIST[0]);
***************
*** 435,440 ****
--- 441,448 ----
  	 * If the cd fails, it doesn't matter.
  	 */
  	(void)vim_chdirfile(fname);
+ 	if (cwd != NULL)
+ 	    mch_dirnamem(cwd, MAXPATHL);
      }
  #endif
      TIME_MSG("expanding arguments");
***************
*** 488,493 ****
--- 496,503 ----
  		expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
  		vim_chdir(NameBuff);
  	    }
+ 	    if (cwd != NULL)
+ 		mch_dirname(cwd, MAXPATHL);
  	}
      }
  #endif
***************
*** 900,907 ****
       * If opened more than one window, start editing files in the other
       * windows.
       */
!     edit_buffers(&params);
  #endif
  
  #ifdef FEAT_DIFF
      if (params.diff_mode)
--- 910,918 ----
       * If opened more than one window, start editing files in the other
       * windows.
       */
!     edit_buffers(&params, cwd);
  #endif
+     vim_free(cwd);
  
  #ifdef FEAT_DIFF
      if (params.diff_mode)
***************
*** 2730,2737 ****
       * windows.  make_windows() has already opened the windows.
       */
      static void
! edit_buffers(parmp)
      mparm_T	*parmp;
  {
      int		arg_idx;		/* index in argument list */
      int		i;
--- 2741,2749 ----
       * windows.  make_windows() has already opened the windows.
       */
      static void
! edit_buffers(parmp, cwd)
      mparm_T	*parmp;
+     char_u	*cwd;			/* current working dir */
  {
      int		arg_idx;		/* index in argument list */
      int		i;
***************
*** 2756,2761 ****
--- 2768,2775 ----
      arg_idx = 1;
      for (i = 1; i < parmp->window_count; ++i)
      {
+ 	if (cwd != NULL)
+ 	    mch_chdir((char *)cwd);
  	/* When w_arg_idx is -1 remove the window (see create_windows()). */
  	if (curwin->w_arg_idx == -1)
  	{
*** ../vim-7.4.688/src/version.c	2015-03-31 19:17:55.620054448 +0200
--- src/version.c	2015-04-03 14:51:43.680122220 +0200
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     689,
  /**/

-- 
Violators can be fined, arrested or jailed for making ugly faces at a dog.
		[real standing law in Oklahoma, United States of America]

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///