aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-08-08 02:22:34 +0200
committerGitHub <noreply@github.com>2018-08-08 02:22:34 +0200
commitb7a417c5e6b510a0023e544463edd6feef30f9d2 (patch)
treeee335ecbd0542a81a3cae584a4165dc0620131d6 /src/nvim/eval.c
parentc06613d2f6c3f3a864c43e03b95d12efb3e0f4a6 (diff)
parentd5e8b3f451120d7b40d72b54d749fbe7b54ca90f (diff)
downloadrneovim-b7a417c5e6b510a0023e544463edd6feef30f9d2.tar.gz
rneovim-b7a417c5e6b510a0023e544463edd6feef30f9d2.tar.bz2
rneovim-b7a417c5e6b510a0023e544463edd6feef30f9d2.zip
Merge #8744 from janlazo/vim-8.0.0890
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ca3c650466..9765b04922 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10210,32 +10210,34 @@ static void f_gettabinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_gettabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
win_T *oldcurwin;
- tabpage_T *tp, *oldtabpage;
- dictitem_T *v;
+ tabpage_T *oldtabpage;
bool done = false;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
const char *const varname = tv_get_string_chk(&argvars[1]);
- tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
+ tabpage_T *const tp = find_tabpage((int)tv_get_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.
- win_T *window = tp->tp_firstwin == NULL ? firstwin : tp->tp_firstwin;
+ win_T *const window = tp == curtab || tp->tp_firstwin == NULL
+ ? firstwin
+ : tp->tp_firstwin;
if (switch_win(&oldcurwin, &oldtabpage, window, tp, true) == OK) {
// look up the variable
// Let gettabvar({nr}, "") return the "t:" dictionary.
- v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't',
- varname, strlen(varname), false);
+ const dictitem_T *const v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't',
+ varname, strlen(varname),
+ false);
if (v != NULL) {
tv_copy(&v->di_tv, rettv);
done = true;
}
}
- /* restore previous notion of curwin */
- restore_win(oldcurwin, oldtabpage, TRUE);
+ // restore previous notion of curwin
+ restore_win(oldcurwin, oldtabpage, true);
}
if (!done && argvars[2].v_type != VAR_UNKNOWN) {