Karsten Hopp d424db
To: vim_dev@googlegroups.com
Karsten Hopp d424db
Subject: Patch 7.4.888
Karsten Hopp d424db
Fcc: outbox
Karsten Hopp d424db
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d424db
Mime-Version: 1.0
Karsten Hopp d424db
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d424db
Content-Transfer-Encoding: 8bit
Karsten Hopp d424db
------------
Karsten Hopp d424db
Karsten Hopp d424db
Patch 7.4.888
Karsten Hopp d424db
Problem:    The OptionSet autocommands are not triggered from setwinvar().
Karsten Hopp d424db
Solution:   Do not use switch_win() when not needed. (Hirohito Higashi)
Karsten Hopp d424db
Files:      src/eval.c
Karsten Hopp d424db
Karsten Hopp d424db
Karsten Hopp d424db
*** ../vim-7.4.887/src/eval.c	2015-09-25 17:37:12.242310841 +0200
Karsten Hopp d424db
--- src/eval.c	2015-09-29 16:07:10.385294539 +0200
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 12420,12431 ****
Karsten Hopp d424db
      typval_T	*rettv;
Karsten Hopp d424db
      int		off;	    /* 1 for gettabwinvar() */
Karsten Hopp d424db
  {
Karsten Hopp d424db
!     win_T	*win, *oldcurwin;
Karsten Hopp d424db
      char_u	*varname;
Karsten Hopp d424db
      dictitem_T	*v;
Karsten Hopp d424db
      tabpage_T	*tp = NULL;
Karsten Hopp d424db
-     tabpage_T	*oldtabpage;
Karsten Hopp d424db
      int		done = FALSE;
Karsten Hopp d424db
  
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
      if (off == 1)
Karsten Hopp d424db
--- 12420,12435 ----
Karsten Hopp d424db
      typval_T	*rettv;
Karsten Hopp d424db
      int		off;	    /* 1 for gettabwinvar() */
Karsten Hopp d424db
  {
Karsten Hopp d424db
!     win_T	*win;
Karsten Hopp d424db
      char_u	*varname;
Karsten Hopp d424db
      dictitem_T	*v;
Karsten Hopp d424db
      tabpage_T	*tp = NULL;
Karsten Hopp d424db
      int		done = FALSE;
Karsten Hopp d424db
+ #ifdef FEAT_WINDOWS
Karsten Hopp d424db
+     win_T	*oldcurwin;
Karsten Hopp d424db
+     tabpage_T	*oldtabpage;
Karsten Hopp d424db
+     int		need_switch_win;
Karsten Hopp d424db
+ #endif
Karsten Hopp d424db
  
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
      if (off == 1)
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 12442,12450 ****
Karsten Hopp d424db
  
Karsten Hopp d424db
      if (win != NULL && varname != NULL)
Karsten Hopp d424db
      {
Karsten Hopp d424db
  	/* Set curwin to be our win, temporarily.  Also set the tabpage,
Karsten Hopp d424db
! 	 * otherwise the window is not valid. */
Karsten Hopp d424db
! 	if (switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
Karsten Hopp d424db
  	{
Karsten Hopp d424db
  	    if (*varname == '&')	/* window-local-option */
Karsten Hopp d424db
  	    {
Karsten Hopp d424db
--- 12446,12459 ----
Karsten Hopp d424db
  
Karsten Hopp d424db
      if (win != NULL && varname != NULL)
Karsten Hopp d424db
      {
Karsten Hopp d424db
+ #ifdef FEAT_WINDOWS
Karsten Hopp d424db
  	/* Set curwin to be our win, temporarily.  Also set the tabpage,
Karsten Hopp d424db
! 	 * otherwise the window is not valid. Only do this when needed,
Karsten Hopp d424db
! 	 * autocommands get blocked. */
Karsten Hopp d424db
! 	need_switch_win = !(tp == curtab && win == curwin);
Karsten Hopp d424db
! 	if (!need_switch_win
Karsten Hopp d424db
! 		  || switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
Karsten Hopp d424db
! #endif
Karsten Hopp d424db
  	{
Karsten Hopp d424db
  	    if (*varname == '&')	/* window-local-option */
Karsten Hopp d424db
  	    {
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 12465,12472 ****
Karsten Hopp d424db
  	    }
Karsten Hopp d424db
  	}
Karsten Hopp d424db
  
Karsten Hopp d424db
! 	/* restore previous notion of curwin */
Karsten Hopp d424db
! 	restore_win(oldcurwin, oldtabpage, TRUE);
Karsten Hopp d424db
      }
Karsten Hopp d424db
  
Karsten Hopp d424db
      if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
Karsten Hopp d424db
--- 12474,12484 ----
Karsten Hopp d424db
  	    }
Karsten Hopp d424db
  	}
Karsten Hopp d424db
  
Karsten Hopp d424db
! #ifdef FEAT_WINDOWS
Karsten Hopp d424db
! 	if (need_switch_win)
Karsten Hopp d424db
! 	    /* restore previous notion of curwin */
Karsten Hopp d424db
! 	    restore_win(oldcurwin, oldtabpage, TRUE);
Karsten Hopp d424db
! #endif
Karsten Hopp d424db
      }
Karsten Hopp d424db
  
Karsten Hopp d424db
      if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 17597,17602 ****
Karsten Hopp d424db
--- 17609,17615 ----
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
      win_T	*save_curwin;
Karsten Hopp d424db
      tabpage_T	*save_curtab;
Karsten Hopp d424db
+     int		need_switch_win;
Karsten Hopp d424db
  #endif
Karsten Hopp d424db
      char_u	*varname, *winvarname;
Karsten Hopp d424db
      typval_T	*varp;
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 17619,17625 ****
Karsten Hopp d424db
      if (win != NULL && varname != NULL && varp != NULL)
Karsten Hopp d424db
      {
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
! 	if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
Karsten Hopp d424db
  #endif
Karsten Hopp d424db
  	{
Karsten Hopp d424db
  	    if (*varname == '&')
Karsten Hopp d424db
--- 17632,17640 ----
Karsten Hopp d424db
      if (win != NULL && varname != NULL && varp != NULL)
Karsten Hopp d424db
      {
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
! 	need_switch_win = !(tp == curtab && win == curwin);
Karsten Hopp d424db
! 	if (!need_switch_win
Karsten Hopp d424db
! 	       || switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
Karsten Hopp d424db
  #endif
Karsten Hopp d424db
  	{
Karsten Hopp d424db
  	    if (*varname == '&')
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 17647,17653 ****
Karsten Hopp d424db
  	    }
Karsten Hopp d424db
  	}
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
! 	restore_win(save_curwin, save_curtab, TRUE);
Karsten Hopp d424db
  #endif
Karsten Hopp d424db
      }
Karsten Hopp d424db
  }
Karsten Hopp d424db
--- 17662,17669 ----
Karsten Hopp d424db
  	    }
Karsten Hopp d424db
  	}
Karsten Hopp d424db
  #ifdef FEAT_WINDOWS
Karsten Hopp d424db
! 	if (need_switch_win)
Karsten Hopp d424db
! 	    restore_win(save_curwin, save_curtab, TRUE);
Karsten Hopp d424db
  #endif
Karsten Hopp d424db
      }
Karsten Hopp d424db
  }
Karsten Hopp d424db
*** ../vim-7.4.887/src/version.c	2015-09-29 15:06:10.783577763 +0200
Karsten Hopp d424db
--- src/version.c	2015-09-29 15:59:58.409791366 +0200
Karsten Hopp d424db
***************
Karsten Hopp d424db
*** 743,744 ****
Karsten Hopp d424db
--- 743,746 ----
Karsten Hopp d424db
  {   /* Add new patch number below this line */
Karsten Hopp d424db
+ /**/
Karsten Hopp d424db
+     888,
Karsten Hopp d424db
  /**/
Karsten Hopp d424db
Karsten Hopp d424db
-- 
Karsten Hopp d424db
Far back in the mists of ancient time, in the great and glorious days of the
Karsten Hopp d424db
former Galactic Empire, life was wild, rich and largely tax free.
Karsten Hopp d424db
Mighty starships plied their way between exotic suns, seeking adventure and
Karsten Hopp d424db
reward among the furthest reaches of Galactic space.  In those days, spirits
Karsten Hopp d424db
were brave, the stakes were high, men were real men, women were real women
Karsten Hopp d424db
and small furry creatures from Alpha Centauri were real small furry creatures
Karsten Hopp d424db
from Alpha Centauri.  And all dared to brave unknown terrors, to do mighty
Karsten Hopp d424db
deeds, to boldly split infinitives that no man had split before -- and thus
Karsten Hopp d424db
was the Empire forged.
Karsten Hopp d424db
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
Karsten Hopp d424db
Karsten Hopp d424db
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d424db
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d424db
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d424db
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///