diff src/evalfunc.c @ 15121:895abc8a5195 v8.1.0571

patch 8.1.0571: non-silent execute() resets display column to zero commit https://github.com/vim/vim/commit/446e7a3cd36b2de7d559f167eb5795d1e1cd3ddb Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 8 13:57:42 2018 +0100 patch 8.1.0571: non-silent execute() resets display column to zero Problem: Non-silent execute() resets display column to zero. Solution: Keep the display column as-is.
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Dec 2018 14:00:07 +0100
parents 2fed75dee954
children 9df130fd5e0d
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3263,6 +3263,7 @@ f_execute(typval_T *argvars, typval_T *r
     int		save_redir_off = redir_off;
     garray_T	save_ga;
     int		save_msg_col = msg_col;
+    int		echo_output = FALSE;
 
     rettv->vval.v_string = NULL;
     rettv->v_type = VAR_STRING;
@@ -3289,6 +3290,8 @@ f_execute(typval_T *argvars, typval_T *r
 
 	if (s == NULL)
 	    return;
+	if (*s == NUL)
+	    echo_output = TRUE;
 	if (STRNCMP(s, "silent", 6) == 0)
 	    ++msg_silent;
 	if (STRCMP(s, "silent!") == 0)
@@ -3305,7 +3308,8 @@ f_execute(typval_T *argvars, typval_T *r
     ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
     redir_execute = TRUE;
     redir_off = FALSE;
-    msg_col = 0;  // prevent leading spaces
+    if (!echo_output)
+	msg_col = 0;  // prevent leading spaces
 
     if (cmd != NULL)
 	do_cmdline_cmd(cmd);
@@ -3339,8 +3343,14 @@ f_execute(typval_T *argvars, typval_T *r
     redir_off = save_redir_off;
 
     // "silent reg" or "silent echo x" leaves msg_col somewhere in the line.
-    // Put it back where it was, since nothing should have been written.
-    msg_col = save_msg_col;
+    if (echo_output)
+	// When not working silently: put it in column zero.  A following
+	// "echon" will overwrite the message, unavoidably.
+	msg_col = 0;
+    else
+	// When working silently: Put it back where it was, since nothing
+	// should have been written.
+	msg_col = save_msg_col;
 }
 
 /*