Karsten Hopp c4ab21
To: vim-dev@vim.org
Karsten Hopp c4ab21
Subject: Patch 7.0.162
Karsten Hopp c4ab21
Fcc: outbox
Karsten Hopp c4ab21
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp c4ab21
Mime-Version: 1.0
Karsten Hopp c4ab21
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp c4ab21
Content-Transfer-Encoding: 8bit
Karsten Hopp c4ab21
------------
Karsten Hopp c4ab21
Karsten Hopp c4ab21
Patch 7.0.162
Karsten Hopp c4ab21
Problem:    "vim -o a b" when file "a" triggers the ATTENTION dialog,
Karsten Hopp c4ab21
	    selecting "Quit" exits Vim instead of editing "b" only.
Karsten Hopp c4ab21
	    When file "b" triggers the ATTENTION dialog selecting "Quit" or
Karsten Hopp c4ab21
	    "Abort" results in editing file "a" in that window.
Karsten Hopp c4ab21
Solution:   When selecting "Abort" exit Vim.  When selecting "Quit" close the
Karsten Hopp c4ab21
	    window.  Also avoid hit-enter prompt when selecting Abort.
Karsten Hopp c4ab21
Files:	    src/buffer.c, src/main.c
Karsten Hopp c4ab21
Karsten Hopp c4ab21
Karsten Hopp c4ab21
*** ../vim-7.0.161/src/buffer.c	Fri Oct 20 20:15:05 2006
Karsten Hopp c4ab21
--- src/buffer.c	Tue Nov  7 21:08:02 2006
Karsten Hopp c4ab21
***************
Karsten Hopp c4ab21
*** 4220,4226 ****
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
      /* Use the name from the associated buffer if it exists. */
Karsten Hopp c4ab21
      bp = buflist_findnr(aep->ae_fnum);
Karsten Hopp c4ab21
!     if (bp == NULL)
Karsten Hopp c4ab21
  	return aep->ae_fname;
Karsten Hopp c4ab21
      return bp->b_fname;
Karsten Hopp c4ab21
  }
Karsten Hopp c4ab21
--- 4222,4228 ----
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
      /* Use the name from the associated buffer if it exists. */
Karsten Hopp c4ab21
      bp = buflist_findnr(aep->ae_fnum);
Karsten Hopp c4ab21
!     if (bp == NULL || bp->b_fname == NULL)
Karsten Hopp c4ab21
  	return aep->ae_fname;
Karsten Hopp c4ab21
      return bp->b_fname;
Karsten Hopp c4ab21
  }
Karsten Hopp c4ab21
*** ../vim-7.0.161/src/main.c	Tue Sep  5 12:57:14 2006
Karsten Hopp c4ab21
--- src/main.c	Tue Nov  7 22:35:49 2006
Karsten Hopp c4ab21
***************
Karsten Hopp c4ab21
*** 2392,2398 ****
Karsten Hopp c4ab21
  		(void)open_buffer(FALSE, NULL); /* create memfile, read file */
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
  #if defined(HAS_SWAP_EXISTS_ACTION)
Karsten Hopp c4ab21
! 		check_swap_exists_action();
Karsten Hopp c4ab21
  #endif
Karsten Hopp c4ab21
  #ifdef FEAT_AUTOCMD
Karsten Hopp c4ab21
  		dorewind = TRUE;		/* start again */
Karsten Hopp c4ab21
--- 2392,2414 ----
Karsten Hopp c4ab21
  		(void)open_buffer(FALSE, NULL); /* create memfile, read file */
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
  #if defined(HAS_SWAP_EXISTS_ACTION)
Karsten Hopp c4ab21
! 		if (swap_exists_action == SEA_QUIT)
Karsten Hopp c4ab21
! 		{
Karsten Hopp c4ab21
! 		    if (got_int || only_one_window())
Karsten Hopp c4ab21
! 		    {
Karsten Hopp c4ab21
! 			/* abort selected or quit and only one window */
Karsten Hopp c4ab21
! 			did_emsg = FALSE;   /* avoid hit-enter prompt */
Karsten Hopp c4ab21
! 			getout(1);
Karsten Hopp c4ab21
! 		    }
Karsten Hopp c4ab21
! 		    /* We can't close the window, it would disturb what
Karsten Hopp c4ab21
! 		     * happens next.  Clear the file name and set the arg
Karsten Hopp c4ab21
! 		     * index to -1 to delete it later. */
Karsten Hopp c4ab21
! 		    setfname(curbuf, NULL, NULL, FALSE);
Karsten Hopp c4ab21
! 		    curwin->w_arg_idx = -1;
Karsten Hopp c4ab21
! 		    swap_exists_action = SEA_NONE;
Karsten Hopp c4ab21
! 		}
Karsten Hopp c4ab21
! 		else
Karsten Hopp c4ab21
! 		    handle_swap_exists(NULL);
Karsten Hopp c4ab21
  #endif
Karsten Hopp c4ab21
  #ifdef FEAT_AUTOCMD
Karsten Hopp c4ab21
  		dorewind = TRUE;		/* start again */
Karsten Hopp c4ab21
***************
Karsten Hopp c4ab21
*** 2432,2437 ****
Karsten Hopp c4ab21
--- 2448,2455 ----
Karsten Hopp c4ab21
  {
Karsten Hopp c4ab21
      int		arg_idx;		/* index in argument list */
Karsten Hopp c4ab21
      int		i;
Karsten Hopp c4ab21
+     int		advance = TRUE;
Karsten Hopp c4ab21
+     buf_T	*old_curbuf;
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
  # ifdef FEAT_AUTOCMD
Karsten Hopp c4ab21
      /*
Karsten Hopp c4ab21
***************
Karsten Hopp c4ab21
*** 2440,2470 ****
Karsten Hopp c4ab21
      ++autocmd_no_enter;
Karsten Hopp c4ab21
      ++autocmd_no_leave;
Karsten Hopp c4ab21
  # endif
Karsten Hopp c4ab21
      arg_idx = 1;
Karsten Hopp c4ab21
      for (i = 1; i < parmp->window_count; ++i)
Karsten Hopp c4ab21
      {
Karsten Hopp c4ab21
! 	if (parmp->window_layout == WIN_TABS)
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
! 	    if (curtab->tp_next == NULL)	/* just checking */
Karsten Hopp c4ab21
! 		break;
Karsten Hopp c4ab21
! 	    goto_tabpage(0);
Karsten Hopp c4ab21
  	}
Karsten Hopp c4ab21
! 	else
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
! 	    if (curwin->w_next == NULL)		/* just checking */
Karsten Hopp c4ab21
! 		break;
Karsten Hopp c4ab21
! 	    win_enter(curwin->w_next, FALSE);
Karsten Hopp c4ab21
  	}
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
  	/* Only open the file if there is no file in this window yet (that can
Karsten Hopp c4ab21
! 	 * happen when .vimrc contains ":sall") */
Karsten Hopp c4ab21
  	if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL)
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
  	    curwin->w_arg_idx = arg_idx;
Karsten Hopp c4ab21
! 	    /* edit file from arg list, if there is one */
Karsten Hopp c4ab21
  	    (void)do_ecmd(0, arg_idx < GARGCOUNT
Karsten Hopp c4ab21
  			  ? alist_name(&GARGLIST[arg_idx]) : NULL,
Karsten Hopp c4ab21
  			  NULL, NULL, ECMD_LASTL, ECMD_HIDE);
Karsten Hopp c4ab21
  	    if (arg_idx == GARGCOUNT - 1)
Karsten Hopp c4ab21
  		arg_had_last = TRUE;
Karsten Hopp c4ab21
  	    ++arg_idx;
Karsten Hopp c4ab21
--- 2458,2522 ----
Karsten Hopp c4ab21
      ++autocmd_no_enter;
Karsten Hopp c4ab21
      ++autocmd_no_leave;
Karsten Hopp c4ab21
  # endif
Karsten Hopp c4ab21
+ 
Karsten Hopp c4ab21
+     /* When w_arg_idx is -1 remove the window (see create_windows()). */
Karsten Hopp c4ab21
+     if (curwin->w_arg_idx == -1)
Karsten Hopp c4ab21
+     {
Karsten Hopp c4ab21
+ 	win_close(curwin, TRUE);
Karsten Hopp c4ab21
+ 	advance = FALSE;
Karsten Hopp c4ab21
+     }
Karsten Hopp c4ab21
+ 
Karsten Hopp c4ab21
      arg_idx = 1;
Karsten Hopp c4ab21
      for (i = 1; i < parmp->window_count; ++i)
Karsten Hopp c4ab21
      {
Karsten Hopp c4ab21
! 	/* When w_arg_idx is -1 remove the window (see create_windows()). */
Karsten Hopp c4ab21
! 	if (curwin->w_arg_idx == -1)
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
! 	    ++arg_idx;
Karsten Hopp c4ab21
! 	    win_close(curwin, TRUE);
Karsten Hopp c4ab21
! 	    advance = FALSE;
Karsten Hopp c4ab21
! 	    continue;
Karsten Hopp c4ab21
  	}
Karsten Hopp c4ab21
! 
Karsten Hopp c4ab21
! 	if (advance)
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
! 	    if (parmp->window_layout == WIN_TABS)
Karsten Hopp c4ab21
! 	    {
Karsten Hopp c4ab21
! 		if (curtab->tp_next == NULL)	/* just checking */
Karsten Hopp c4ab21
! 		    break;
Karsten Hopp c4ab21
! 		goto_tabpage(0);
Karsten Hopp c4ab21
! 	    }
Karsten Hopp c4ab21
! 	    else
Karsten Hopp c4ab21
! 	    {
Karsten Hopp c4ab21
! 		if (curwin->w_next == NULL)	/* just checking */
Karsten Hopp c4ab21
! 		    break;
Karsten Hopp c4ab21
! 		win_enter(curwin->w_next, FALSE);
Karsten Hopp c4ab21
! 	    }
Karsten Hopp c4ab21
  	}
Karsten Hopp c4ab21
+ 	advance = TRUE;
Karsten Hopp c4ab21
  
Karsten Hopp c4ab21
  	/* Only open the file if there is no file in this window yet (that can
Karsten Hopp c4ab21
! 	 * happen when .vimrc contains ":sall"). */
Karsten Hopp c4ab21
  	if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL)
Karsten Hopp c4ab21
  	{
Karsten Hopp c4ab21
  	    curwin->w_arg_idx = arg_idx;
Karsten Hopp c4ab21
! 	    /* Edit file from arg list, if there is one.  When "Quit" selected
Karsten Hopp c4ab21
! 	     * at the ATTENTION prompt close the window. */
Karsten Hopp c4ab21
! 	    old_curbuf = curbuf;
Karsten Hopp c4ab21
  	    (void)do_ecmd(0, arg_idx < GARGCOUNT
Karsten Hopp c4ab21
  			  ? alist_name(&GARGLIST[arg_idx]) : NULL,
Karsten Hopp c4ab21
  			  NULL, NULL, ECMD_LASTL, ECMD_HIDE);
Karsten Hopp c4ab21
+ 	    if (curbuf == old_curbuf)
Karsten Hopp c4ab21
+ 	    {
Karsten Hopp c4ab21
+ 		if (got_int || only_one_window())
Karsten Hopp c4ab21
+ 		{
Karsten Hopp c4ab21
+ 		    /* abort selected or quit and only one window */
Karsten Hopp c4ab21
+ 		    did_emsg = FALSE;   /* avoid hit-enter prompt */
Karsten Hopp c4ab21
+ 		    getout(1);
Karsten Hopp c4ab21
+ 		}
Karsten Hopp c4ab21
+ 		win_close(curwin, TRUE);
Karsten Hopp c4ab21
+ 		advance = FALSE;
Karsten Hopp c4ab21
+ 	    }
Karsten Hopp c4ab21
  	    if (arg_idx == GARGCOUNT - 1)
Karsten Hopp c4ab21
  		arg_had_last = TRUE;
Karsten Hopp c4ab21
  	    ++arg_idx;
Karsten Hopp c4ab21
*** ../vim-7.0.161/src/version.c	Tue Nov  7 19:05:36 2006
Karsten Hopp c4ab21
--- src/version.c	Tue Nov  7 21:21:28 2006
Karsten Hopp c4ab21
***************
Karsten Hopp c4ab21
*** 668,669 ****
Karsten Hopp c4ab21
--- 668,671 ----
Karsten Hopp c4ab21
  {   /* Add new patch number below this line */
Karsten Hopp c4ab21
+ /**/
Karsten Hopp c4ab21
+     162,
Karsten Hopp c4ab21
  /**/
Karsten Hopp c4ab21
Karsten Hopp c4ab21
-- 
Karsten Hopp c4ab21
The CIA drives around in cars with the "Intel inside" logo.
Karsten Hopp c4ab21
Karsten Hopp c4ab21
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp c4ab21
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp c4ab21
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp c4ab21
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///