diff options
Diffstat (limited to 'src/nvim/eval.c')
| -rw-r--r-- | src/nvim/eval.c | 20 | 
1 files changed, 15 insertions, 5 deletions
| diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 71cb83e566..d058e6ccae 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6652,7 +6652,7 @@ char_u *get_function_name(expand_T *xp, int idx)      if (name != NULL)        return name;    } -  if (++intidx < (int)(sizeof(functions) / sizeof(struct fst))) { +  if (++intidx < (int)ARRAY_SIZE(functions)) {      STRCPY(IObuff, functions[intidx].f_name);      STRCAT(IObuff, "(");      if (functions[intidx].f_max_argc == 0) @@ -6695,7 +6695,7 @@ find_internal_func (  )  {    int first = 0; -  int last = (int)(sizeof(functions) / sizeof(struct fst)) - 1; +  int last = (int)ARRAY_SIZE(functions) - 1;    /*     * Find the function name in the table. Binary search. @@ -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 *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 tp to be our tabpage, temporarily.  Also set the window to the +     * first window in the tabpage, otherwise the window is not valid. */ +    switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, 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); +  }  }  /* | 
