diff options
author | Florian Walch <florian@fwalch.com> | 2014-12-18 17:44:56 +0100 |
---|---|---|
committer | Florian Walch <florian@fwalch.com> | 2014-12-18 21:22:40 +0100 |
commit | 815fe2845015e61bb5aaf46b458b8fbc5a4218b3 (patch) | |
tree | 15681b0352cd3bf3dc2d214393079586ce401911 /src/nvim/eval.c | |
parent | bd19cc4f8fc3d02a030caba911a1af008585f688 (diff) | |
download | rneovim-815fe2845015e61bb5aaf46b458b8fbc5a4218b3.tar.gz rneovim-815fe2845015e61bb5aaf46b458b8fbc5a4218b3.tar.bz2 rneovim-815fe2845015e61bb5aaf46b458b8fbc5a4218b3.zip |
vim-patch:7.4.434
Problem: gettabvar() is not consistent with getwinvar() and getbufvar().
Solution: Return a dict with all variables when the varname is empty.
(Yasuhiro Matsumoto)
https://code.google.com/p/vim/source/detail?r=v7-4-434
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..ac557eb07f 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 *win, *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 curwin to be our win, temporarily. Also set the tabpage, + * otherwise the window is not valid. */ + switch_win(&oldcurwin, &oldtabpage, win, 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); + } } /* |