changeset 9525:858bd3176f30 v7.4.2043

commit https://github.com/vim/vim/commit/93431df9eb02f7cf3d7f2142bb1bef24c5f325b2 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 15 20:14:44 2016 +0200 patch 7.4.2043 Problem: setbuvfar() causes a screen redraw. Solution: Only use aucmd_prepbuf() for options.
author Christian Brabandt <cb@256bit.org>
date Fri, 15 Jul 2016 20:15:06 +0200
parents 2976e2d609df
children 911a70945374
files src/eval.c src/version.c
diffstat 2 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -18495,7 +18495,6 @@ f_serverlist(typval_T *argvars UNUSED, t
 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 
 
     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);
-	}
-	else
-	{
+
+	    /* 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);
-	    }
-	}
-
-	/* reset notion of buffer */
-	aucmd_restbuf(&aco);
+		curbuf = save_curbuf;
+	    }
+	}
     }
 }
 
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2043,
+/**/
     2042,
 /**/
     2041,