Skip to content

Instantly share code, notes, and snippets.

@mattn
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/f606cccc62d2171ad6d1 to your computer and use it in GitHub Desktop.
Save mattn/f606cccc62d2171ad6d1 to your computer and use it in GitHub Desktop.
diff -r 35ec194cce5b src/eval.c
--- a/src/eval.c Fri Aug 29 17:45:32 2014 +0200
+++ b/src/eval.c Sun Aug 31 20:42:31 2014 +0900
@@ -12071,7 +12071,8 @@
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 @@
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment