Skip to content

Commit ba117c2

Browse files
committed
patch 7.4.888
Problem: The OptionSet autocommands are not triggered from setwinvar(). Solution: Do not use switch_win() when not needed. (Hirohito Higashi)
1 parent c2b717e commit ba117c2

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/eval.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12420,12 +12420,16 @@ getwinvar(argvars, rettv, off)
1242012420
typval_T *rettv;
1242112421
int off; /* 1 for gettabwinvar() */
1242212422
{
12423-
win_T *win, *oldcurwin;
12423+
win_T *win;
1242412424
char_u *varname;
1242512425
dictitem_T *v;
1242612426
tabpage_T *tp = NULL;
12427-
tabpage_T *oldtabpage;
1242812427
int done = FALSE;
12428+
#ifdef FEAT_WINDOWS
12429+
win_T *oldcurwin;
12430+
tabpage_T *oldtabpage;
12431+
int need_switch_win;
12432+
#endif
1242912433

1243012434
#ifdef FEAT_WINDOWS
1243112435
if (off == 1)
@@ -12442,9 +12446,14 @@ getwinvar(argvars, rettv, off)
1244212446

1244312447
if (win != NULL && varname != NULL)
1244412448
{
12449+
#ifdef FEAT_WINDOWS
1244512450
/* Set curwin to be our win, temporarily. Also set the tabpage,
12446-
* otherwise the window is not valid. */
12447-
if (switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
12451+
* otherwise the window is not valid. Only do this when needed,
12452+
* autocommands get blocked. */
12453+
need_switch_win = !(tp == curtab && win == curwin);
12454+
if (!need_switch_win
12455+
|| switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
12456+
#endif
1244812457
{
1244912458
if (*varname == '&') /* window-local-option */
1245012459
{
@@ -12465,8 +12474,11 @@ getwinvar(argvars, rettv, off)
1246512474
}
1246612475
}
1246712476

12468-
/* restore previous notion of curwin */
12469-
restore_win(oldcurwin, oldtabpage, TRUE);
12477+
#ifdef FEAT_WINDOWS
12478+
if (need_switch_win)
12479+
/* restore previous notion of curwin */
12480+
restore_win(oldcurwin, oldtabpage, TRUE);
12481+
#endif
1247012482
}
1247112483

1247212484
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
@@ -17597,6 +17609,7 @@ setwinvar(argvars, rettv, off)
1759717609
#ifdef FEAT_WINDOWS
1759817610
win_T *save_curwin;
1759917611
tabpage_T *save_curtab;
17612+
int need_switch_win;
1760017613
#endif
1760117614
char_u *varname, *winvarname;
1760217615
typval_T *varp;
@@ -17619,7 +17632,9 @@ setwinvar(argvars, rettv, off)
1761917632
if (win != NULL && varname != NULL && varp != NULL)
1762017633
{
1762117634
#ifdef FEAT_WINDOWS
17622-
if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
17635+
need_switch_win = !(tp == curtab && win == curwin);
17636+
if (!need_switch_win
17637+
|| switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
1762317638
#endif
1762417639
{
1762517640
if (*varname == '&')
@@ -17647,7 +17662,8 @@ setwinvar(argvars, rettv, off)
1764717662
}
1764817663
}
1764917664
#ifdef FEAT_WINDOWS
17650-
restore_win(save_curwin, save_curtab, TRUE);
17665+
if (need_switch_win)
17666+
restore_win(save_curwin, save_curtab, TRUE);
1765117667
#endif
1765217668
}
1765317669
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
888,
744746
/**/
745747
887,
746748
/**/

0 commit comments

Comments
 (0)