diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-12-19 01:35:42 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-12-19 01:35:42 -0500 |
commit | 5df8bf077bc69eab4e660dc09026878adcf54bb8 (patch) | |
tree | 9a810ddb2c0508bf6ba9033f3d8087eb9f148b59 /src/nvim/eval.c | |
parent | e47105c47dd8436149ad38cbea0587a331490db4 (diff) | |
parent | 3f7b8199df130145143016536e3cc46fd8ef65ff (diff) | |
download | rneovim-5df8bf077bc69eab4e660dc09026878adcf54bb8.tar.gz rneovim-5df8bf077bc69eab4e660dc09026878adcf54bb8.tar.bz2 rneovim-5df8bf077bc69eab4e660dc09026878adcf54bb8.zip |
Merge pull request #1704 from fwalch/vim-7.4.434
vim-patch:7.4.434, vim-patch:7.4.442
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 71cb83e566..c79a467889 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9603,7 +9603,8 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv) */ static void f_gettabvar(typval_T *argvars, typval_T *rettv) { - tabpage_T *tp; + win_T *oldcurwin; + tabpage_T *tp, *oldtabpage; dictitem_T *v; char_u *varname; int done = FALSE; @@ -9614,16 +9615,25 @@ static void f_gettabvar(typval_T *argvars, typval_T *rettv) varname = get_tv_string_chk(&argvars[1]); tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL)); if (tp != NULL && varname != NULL) { + /* Set tp to be our tabpage, temporarily. Also set the window to the + * first window in the tabpage, otherwise the window is not valid. */ + switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, tp, TRUE); + /* look up the variable */ - v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE); + /* Let gettabvar({nr}, "") return the "t:" dictionary. */ + v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE); if (v != NULL) { copy_tv(&v->di_tv, rettv); done = TRUE; } + + /* restore previous notion of curwin */ + restore_win(oldcurwin, oldtabpage, TRUE); } - if (!done && argvars[2].v_type != VAR_UNKNOWN) + if (!done && argvars[2].v_type != VAR_UNKNOWN) { copy_tv(&argvars[2], rettv); + } } /* |