diff options
Diffstat (limited to 'src/nvim/eval.c')
| -rw-r--r-- | src/nvim/eval.c | 80 | 
1 files changed, 46 insertions, 34 deletions
| diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 327d0bf637..94683d22cb 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3580,9 +3580,10 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate)        type = TYPE_SEQUAL;      break;    case 'i':   if (p[1] == 's') { -      if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') +      if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') {          len = 5; -      if (!vim_isIDc(p[len])) { +      } +      if (!isalnum(p[len]) && p[len] != '_') {          type = len == 2 ? TYPE_EQUAL : TYPE_NEQUAL;          type_is = TRUE;        } @@ -10697,11 +10698,11 @@ getwinvar (      int off                    /* 1 for gettabwinvar() */  )  { -  win_T       *win, *oldcurwin; -  char_u      *varname; -  dictitem_T  *v; -  tabpage_T   *tp = NULL; -  tabpage_T   *oldtabpage = NULL; +  win_T *win, *oldcurwin; +  char_u *varname; +  dictitem_T *v; +  tabpage_T *tp = NULL; +  tabpage_T *oldtabpage = NULL;    bool done = false;    if (off == 1) @@ -10716,12 +10717,16 @@ getwinvar (    rettv->vval.v_string = NULL;    if (win != NULL && varname != NULL) { -    /* Set curwin to be our win, temporarily.  Also set the tabpage, -     * otherwise the window is not valid. */ -    if (switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK) { -      if (*varname == '&') {      /* window-local-option */ -        if (get_option_tv(&varname, rettv, 1) == OK) +    // Set curwin to be our win, temporarily.  Also set the tabpage, +    // otherwise the window is not valid. Only do this when needed, +    // autocommands get blocked. +    bool need_switch_win = tp != curtab || win != curwin; +    if (!need_switch_win +        || switch_win(&oldcurwin, &oldtabpage, win, tp, true) == OK) { +      if (*varname == '&') {  // window-local-option +        if (get_option_tv(&varname, rettv, 1) == OK) {            done = true; +        }        } else {          // Look up the variable.          // Let getwinvar({nr}, "") return the "w:" dictionary. @@ -10733,8 +10738,10 @@ getwinvar (        }      } -    /* restore previous notion of curwin */ -    restore_win(oldcurwin, oldtabpage, TRUE); +    if (need_switch_win) { +      // restore previous notion of curwin +      restore_win(oldcurwin, oldtabpage, true); +    }    }    if (!done && argvars[off + 2].v_type != VAR_UNKNOWN) @@ -15559,26 +15566,32 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off)    varname = get_tv_string_chk(&argvars[off + 1]);    varp = &argvars[off + 2]; -  if (win != NULL && varname != NULL && varp != NULL -      && switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK) { -    if (*varname == '&') { -      long numval; -      char_u      *strval; -      int error = FALSE; - -      ++varname; -      numval = get_tv_number_chk(varp, &error); -      strval = get_tv_string_buf_chk(varp, nbuf); -      if (!error && strval != NULL) -        set_option_value(varname, numval, strval, OPT_LOCAL); -    } else { -      winvarname = xmalloc(STRLEN(varname) + 3); -      STRCPY(winvarname, "w:"); -      STRCPY(winvarname + 2, varname); -      set_var(winvarname, varp, TRUE); -      xfree(winvarname); +  if (win != NULL && varname != NULL && varp != NULL) { +    bool need_switch_win = tp != curtab || win != curwin; +    if (!need_switch_win +        || switch_win(&save_curwin, &save_curtab, win, tp, true) == OK) { +      if (*varname == '&') { +        long numval; +        char_u *strval; +        int error = false; + +        ++varname; +        numval = get_tv_number_chk(varp, &error); +        strval = get_tv_string_buf_chk(varp, nbuf); +        if (!error && strval != NULL) { +          set_option_value(varname, numval, strval, OPT_LOCAL); +        } +      } else { +        winvarname = xmalloc(STRLEN(varname) + 3); +        STRCPY(winvarname, "w:"); +        STRCPY(winvarname + 2, varname); +        set_var(winvarname, varp, true); +        xfree(winvarname); +      } +    } +    if (need_switch_win) { +      restore_win(save_curwin, save_curtab, true);      } -    restore_win(save_curwin, save_curtab, TRUE);    }  } @@ -22186,7 +22199,6 @@ static void on_process_exit(Process *proc, int status, void *d)      char msg[22];      snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status);      terminal_close(data->term, msg); -    apply_autocmds(EVENT_TERMCLOSE, NULL, NULL, false, curbuf);    }    if (data->status_ptr) { | 
