444cac1
To: vim-dev@vim.org
444cac1
Subject: Patch 7.1.182
444cac1
Fcc: outbox
444cac1
From: Bram Moolenaar <Bram@moolenaar.net>
444cac1
Mime-Version: 1.0
444cac1
Content-Type: text/plain; charset=ISO-8859-1
444cac1
Content-Transfer-Encoding: 8bit
444cac1
------------
444cac1
444cac1
Patch 7.1.182
444cac1
Problem:    When using tab pages and an argument list the session file may
444cac1
	    contain wrong "next" commands. (Alexander Bluem)
444cac1
Solution:   Use "argu" commands and only when needed.
444cac1
Files:	    src/ex_docmd.c
444cac1
444cac1
444cac1
*** ../vim-7.1.181/src/ex_docmd.c	Sun Dec  9 19:37:37 2007
444cac1
--- src/ex_docmd.c	Mon Dec 31 18:24:16 2007
444cac1
***************
444cac1
*** 372,378 ****
444cac1
  static char_u	*arg_all __ARGS((void));
444cac1
  #ifdef FEAT_SESSION
444cac1
  static int	makeopens __ARGS((FILE *fd, char_u *dirnow));
444cac1
! static int	put_view __ARGS((FILE *fd, win_T *wp, int add_edit, unsigned *flagp));
444cac1
  static void	ex_loadview __ARGS((exarg_T *eap));
444cac1
  static char_u	*get_view_file __ARGS((int c));
444cac1
  static int	did_lcd;	/* whether ":lcd" was produced for a session */
444cac1
--- 372,378 ----
444cac1
  static char_u	*arg_all __ARGS((void));
444cac1
  #ifdef FEAT_SESSION
444cac1
  static int	makeopens __ARGS((FILE *fd, char_u *dirnow));
444cac1
! static int	put_view __ARGS((FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx));
444cac1
  static void	ex_loadview __ARGS((exarg_T *eap));
444cac1
  static char_u	*get_view_file __ARGS((int c));
444cac1
  static int	did_lcd;	/* whether ":lcd" was produced for a session */
444cac1
***************
444cac1
*** 8762,8768 ****
444cac1
  	    }
444cac1
  	    else
444cac1
  	    {
444cac1
! 		failed |= (put_view(fd, curwin, !using_vdir, flagp) == FAIL);
444cac1
  	    }
444cac1
  	    if (put_line(fd, "let &so = s:so_save | let &siso = s:siso_save")
444cac1
  								      == FAIL)
444cac1
--- 8762,8769 ----
444cac1
  	    }
444cac1
  	    else
444cac1
  	    {
444cac1
! 		failed |= (put_view(fd, curwin, !using_vdir, flagp,
444cac1
! 								 -1) == FAIL);
444cac1
  	    }
444cac1
  	    if (put_line(fd, "let &so = s:so_save | let &siso = s:siso_save")
444cac1
  								      == FAIL)
444cac1
***************
444cac1
*** 9761,9766 ****
444cac1
--- 9762,9769 ----
444cac1
      int		tabnr;
444cac1
      win_T	*tab_firstwin;
444cac1
      frame_T	*tab_topframe;
444cac1
+     int		cur_arg_idx = 0;
444cac1
+     int		next_arg_idx;
444cac1
  
444cac1
      if (ssop_flags & SSOP_BUFFERS)
444cac1
  	only_save_windows = FALSE;		/* Save ALL buffers */
444cac1
***************
444cac1
*** 9976,9987 ****
444cac1
  	{
444cac1
  	    if (!ses_do_win(wp))
444cac1
  		continue;
444cac1
! 	    if (put_view(fd, wp, wp != edited_win, &ssop_flags) == FAIL)
444cac1
  		return FAIL;
444cac1
  	    if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
444cac1
  		return FAIL;
444cac1
  	}
444cac1
  
444cac1
  	/*
444cac1
  	 * Restore cursor to the current window if it's not the first one.
444cac1
  	 */
444cac1
--- 9979,9997 ----
444cac1
  	{
444cac1
  	    if (!ses_do_win(wp))
444cac1
  		continue;
444cac1
! 	    if (put_view(fd, wp, wp != edited_win, &ssop_flags,
444cac1
! 							 cur_arg_idx) == FAIL)
444cac1
  		return FAIL;
444cac1
  	    if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
444cac1
  		return FAIL;
444cac1
+ 	    next_arg_idx = wp->w_arg_idx;
444cac1
  	}
444cac1
  
444cac1
+ 	/* The argument index in the first tab page is zero, need to set it in
444cac1
+ 	 * each window.  For further tab pages it's the window where we do
444cac1
+ 	 * "tabedit". */
444cac1
+ 	cur_arg_idx = next_arg_idx;
444cac1
+ 
444cac1
  	/*
444cac1
  	 * Restore cursor to the current window if it's not the first one.
444cac1
  	 */
444cac1
***************
444cac1
*** 10190,10200 ****
444cac1
   * Caller must make sure 'scrolloff' is zero.
444cac1
   */
444cac1
      static int
444cac1
! put_view(fd, wp, add_edit, flagp)
444cac1
      FILE	*fd;
444cac1
      win_T	*wp;
444cac1
      int		add_edit;	/* add ":edit" command to view */
444cac1
      unsigned	*flagp;		/* vop_flags or ssop_flags */
444cac1
  {
444cac1
      win_T	*save_curwin;
444cac1
      int		f;
444cac1
--- 10200,10212 ----
444cac1
   * Caller must make sure 'scrolloff' is zero.
444cac1
   */
444cac1
      static int
444cac1
! put_view(fd, wp, add_edit, flagp, current_arg_idx)
444cac1
      FILE	*fd;
444cac1
      win_T	*wp;
444cac1
      int		add_edit;	/* add ":edit" command to view */
444cac1
      unsigned	*flagp;		/* vop_flags or ssop_flags */
444cac1
+     int		current_arg_idx; /* current argument index of the window, use
444cac1
+ 				  * -1 if unknown */
444cac1
  {
444cac1
      win_T	*save_curwin;
444cac1
      int		f;
444cac1
***************
444cac1
*** 10224,10233 ****
444cac1
  
444cac1
      /* Only when part of a session: restore the argument index.  Some
444cac1
       * arguments may have been deleted, check if the index is valid. */
444cac1
!     if (wp->w_arg_idx != 0 && wp->w_arg_idx <= WARGCOUNT(wp)
444cac1
  						      && flagp == &ssop_flags)
444cac1
      {
444cac1
! 	if (fprintf(fd, "%ldnext", (long)wp->w_arg_idx) < 0
444cac1
  		|| put_eol(fd) == FAIL)
444cac1
  	    return FAIL;
444cac1
  	did_next = TRUE;
444cac1
--- 10236,10245 ----
444cac1
  
444cac1
      /* Only when part of a session: restore the argument index.  Some
444cac1
       * arguments may have been deleted, check if the index is valid. */
444cac1
!     if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx <= WARGCOUNT(wp)
444cac1
  						      && flagp == &ssop_flags)
444cac1
      {
444cac1
! 	if (fprintf(fd, "%ldargu", (long)wp->w_arg_idx + 1) < 0
444cac1
  		|| put_eol(fd) == FAIL)
444cac1
  	    return FAIL;
444cac1
  	did_next = TRUE;
444cac1
*** ../vim-7.1.181/src/version.c	Wed Jan  2 13:58:17 2008
444cac1
--- src/version.c	Wed Jan  2 15:10:01 2008
444cac1
***************
444cac1
*** 668,669 ****
444cac1
--- 668,671 ----
444cac1
  {   /* Add new patch number below this line */
444cac1
+ /**/
444cac1
+     182,
444cac1
  /**/
444cac1
444cac1
-- 
444cac1
You were lucky. We lived for three months in a brown paper bag in a 
444cac1
septic tank. We used to have to get up at six o'clock in the morning, 
444cac1
clean the bag, eat a crust of stale bread, go to work down mill for 
444cac1
fourteen hours a day week in-week out. When we got home, our Dad
444cac1
would thrash us to sleep with his belt!
444cac1
444cac1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
444cac1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
444cac1
\\\        download, build and distribute -- http://www.A-A-P.org        ///
444cac1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///