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