Last active
September 25, 2015 22:17
-
-
Save h-east/a26febcb48eb868b0676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/eval.c b/src/eval.c | |
--- a/src/eval.c | |
+++ b/src/eval.c | |
@@ -12426,6 +12426,7 @@ | |
tabpage_T *tp = NULL; | |
tabpage_T *oldtabpage; | |
int done = FALSE; | |
+ int is_switch; | |
#ifdef FEAT_WINDOWS | |
if (off == 1) | |
@@ -12442,9 +12443,11 @@ | |
if (win != NULL && varname != NULL) | |
{ | |
+ is_switch = !(tp == curtab && win == curwin); | |
/* Set curwin to be our win, temporarily. Also set the tabpage, | |
* otherwise the window is not valid. */ | |
- if (switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK) | |
+ if (!is_switch || | |
+ switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK) | |
{ | |
if (*varname == '&') /* window-local-option */ | |
{ | |
@@ -12465,8 +12468,9 @@ | |
} | |
} | |
- /* restore previous notion of curwin */ | |
- restore_win(oldcurwin, oldtabpage, TRUE); | |
+ if (is_switch) | |
+ /* restore previous notion of curwin */ | |
+ restore_win(oldcurwin, oldtabpage, TRUE); | |
} | |
if (!done && argvars[off + 2].v_type != VAR_UNKNOWN) | |
@@ -17597,6 +17601,7 @@ | |
#ifdef FEAT_WINDOWS | |
win_T *save_curwin; | |
tabpage_T *save_curtab; | |
+ int is_switch; | |
#endif | |
char_u *varname, *winvarname; | |
typval_T *varp; | |
@@ -17619,7 +17624,9 @@ | |
if (win != NULL && varname != NULL && varp != NULL) | |
{ | |
#ifdef FEAT_WINDOWS | |
- if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK) | |
+ is_switch = !(tp == curtab && win == curwin); | |
+ if (!is_switch || | |
+ switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK) | |
#endif | |
{ | |
if (*varname == '&') | |
@@ -17647,7 +17654,8 @@ | |
} | |
} | |
#ifdef FEAT_WINDOWS | |
- restore_win(save_curwin, save_curtab, TRUE); | |
+ if (is_switch) | |
+ restore_win(save_curwin, save_curtab, TRUE); | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment