summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c
index 6987485ed..e29ba735a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -18495,7 +18495,6 @@ f_serverlist(typval_T *argvars UNUSED, typval_T *rettv)
f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
{
buf_T *buf;
- aco_save_T aco;
char_u *varname, *bufvarname;
typval_T *varp;
char_u nbuf[NUMBUFLEN];
@@ -18509,35 +18508,40 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
if (buf != NULL && varname != NULL && varp != NULL)
{
- /* set curbuf to be our buf, temporarily */
- aucmd_prepbuf(&aco, buf);
-
if (*varname == '&')
{
long numval;
char_u *strval;
int error = FALSE;
+ aco_save_T aco;
+
+ /* set curbuf to be our buf, temporarily */
+ aucmd_prepbuf(&aco, buf);
++varname;
numval = (long)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);
+
+ /* reset notion of buffer */
+ aucmd_restbuf(&aco);
}
else
{
+ buf_T *save_curbuf = curbuf;
+
bufvarname = alloc((unsigned)STRLEN(varname) + 3);
if (bufvarname != NULL)
{
+ curbuf = buf;
STRCPY(bufvarname, "b:");
STRCPY(bufvarname + 2, varname);
set_var(bufvarname, varp, TRUE);
vim_free(bufvarname);
+ curbuf = save_curbuf;
}
}
-
- /* reset notion of buffer */
- aucmd_restbuf(&aco);
}
}