diff options
author | Jurica Bradaric <jbradaric@gmail.com> | 2016-02-11 23:01:30 +0100 |
---|---|---|
committer | Jurica Bradaric <jbradaric@gmail.com> | 2016-02-15 11:05:17 +0100 |
commit | de23395fa75547259bf9ded9c7571e7a260160c3 (patch) | |
tree | 17e3bee4ee8d79b5ce60bf57e7c381a11300aee1 /src | |
parent | 7609a96a35224be3d7f3ba77691f9115e0281b4e (diff) | |
download | rneovim-de23395fa75547259bf9ded9c7571e7a260160c3.tar.gz rneovim-de23395fa75547259bf9ded9c7571e7a260160c3.tar.bz2 rneovim-de23395fa75547259bf9ded9c7571e7a260160c3.zip |
vim-patch:7.4.888
Problem: The OptionSet autocommands are not triggered from setwinvar().
Solution: Do not use switch_win() when not needed. (Hirohito Higashi)
https://github.com/vim/vim/commit/ba117c23dfd1146aca3235bea172df17a48bccee
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 74 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 44 insertions, 32 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 327d0bf637..0f8c55e993 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10697,11 +10697,11 @@ getwinvar ( int off /* 1 for gettabwinvar() */ ) { - win_T *win, *oldcurwin; - char_u *varname; - dictitem_T *v; - tabpage_T *tp = NULL; - tabpage_T *oldtabpage = NULL; + win_T *win, *oldcurwin; + char_u *varname; + dictitem_T *v; + tabpage_T *tp = NULL; + tabpage_T *oldtabpage = NULL; bool done = false; if (off == 1) @@ -10716,12 +10716,16 @@ getwinvar ( rettv->vval.v_string = NULL; if (win != NULL && varname != NULL) { - /* 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 (*varname == '&') { /* window-local-option */ - if (get_option_tv(&varname, rettv, 1) == OK) + // Set curwin to be our win, temporarily. Also set the tabpage, + // otherwise the window is not valid. Only do this when needed, + // autocommands get blocked. + bool need_switch_win = tp != curtab || win != curwin; + if (!need_switch_win + || switch_win(&oldcurwin, &oldtabpage, win, tp, true) == OK) { + if (*varname == '&') { // window-local-option + if (get_option_tv(&varname, rettv, 1) == OK) { done = true; + } } else { // Look up the variable. // Let getwinvar({nr}, "") return the "w:" dictionary. @@ -10733,8 +10737,10 @@ getwinvar ( } } - /* restore previous notion of curwin */ - restore_win(oldcurwin, oldtabpage, TRUE); + if (need_switch_win) { + // restore previous notion of curwin + restore_win(oldcurwin, oldtabpage, true); + } } if (!done && argvars[off + 2].v_type != VAR_UNKNOWN) @@ -15559,26 +15565,32 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off) varname = get_tv_string_chk(&argvars[off + 1]); varp = &argvars[off + 2]; - if (win != NULL && varname != NULL && varp != NULL - && switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK) { - if (*varname == '&') { - long numval; - char_u *strval; - int error = FALSE; - - ++varname; - numval = get_tv_number_chk(varp, &error); - strval = get_tv_string_buf_chk(varp, nbuf); - if (!error && strval != NULL) - set_option_value(varname, numval, strval, OPT_LOCAL); - } else { - winvarname = xmalloc(STRLEN(varname) + 3); - STRCPY(winvarname, "w:"); - STRCPY(winvarname + 2, varname); - set_var(winvarname, varp, TRUE); - xfree(winvarname); + if (win != NULL && varname != NULL && varp != NULL) { + bool need_switch_win = tp != curtab || win != curwin; + if (!need_switch_win + || switch_win(&save_curwin, &save_curtab, win, tp, true) == OK) { + if (*varname == '&') { + long numval; + char_u *strval; + int error = false; + + ++varname; + numval = get_tv_number_chk(varp, &error); + strval = get_tv_string_buf_chk(varp, nbuf); + if (!error && strval != NULL) { + set_option_value(varname, numval, strval, OPT_LOCAL); + } + } else { + winvarname = xmalloc(STRLEN(varname) + 3); + STRCPY(winvarname, "w:"); + STRCPY(winvarname + 2, varname); + set_var(winvarname, varp, TRUE); + xfree(winvarname); + } + } + if (need_switch_win) { + restore_win(save_curwin, save_curtab, true); } - restore_win(save_curwin, save_curtab, TRUE); } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 4de63ebb10..7526151652 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -400,7 +400,7 @@ static int included_patches[] = { // 891, // 890 NA // 889, - // 888, + 888, 887, // 886 NA // 885, |