diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-09-09 16:13:08 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-09-09 16:13:08 +0200 |
commit | 0e2ea1beb471a24dd86a45c439a98e5d758b4270 (patch) | |
tree | ca16549dc5cc12a841dcc0492f800247759c3910 /src/eval.c | |
parent | 13e2a0af665cffa3c4485be843feca70d90a7918 (diff) | |
download | vim-0e2ea1beb471a24dd86a45c439a98e5d758b4270.zip |
updated for version 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)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c index 7bf52c5f3..8303bd375 100644 --- a/src/eval.c +++ b/src/eval.c @@ -12071,7 +12071,8 @@ f_gettabvar(argvars, rettv) 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; @@ -12083,13 +12084,21 @@ f_gettabvar(argvars, rettv) 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) |