neovim/neovim — pull request #1704 by fwalch (2014-12-18 17:21:03+00:00)
Title: [RFC] 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
```

Original patch:

```diff
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3575,6 +3575,8 @@ gettabvar({tabnr}, {varname} [, {def}])
Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var|
Tabs are numbered starting with one.
+	When {varname} is empty a dictionary with all tab-local
+	variables is returned.
Note that the name without "t:" must be used.
When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message.
diff --git a/src/eval.c b/src/eval.c
--- 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)
diff --git a/src/testdir/test91.in b/src/testdir/test91.in
--- a/src/testdir/test91.in
+++ b/src/testdir/test91.in
@@ -55,6 +55,7 @@ STARTTEST
:tabnew
:tabnew
:let t:var_list = [1, 2, 3]
+:let t:other = 777
:let def_list = [4, 5, 6, 7]
:tabrewind
:$put =string(gettabvar(3, 'var_list'))
diff --git a/src/testdir/test91.ok b/src/testdir/test91.ok
--- a/src/testdir/test91.ok
+++ b/src/testdir/test91.ok
@@ -26,8 +26,8 @@ 0
0
[1, 2, 3]
[1, 2, 3]
-''
-[4, 5, 6, 7]
+{'var_list': [1, 2, 3], 'other': 777}
+{'var_list': [1, 2, 3], 'other': 777}
[4, 5, 6, 7]
''
[4, 5, 6, 7]
diff --git a/src/version.c b/src/version.c
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 434,
+/**/
433,
/**/
432,
```