Skip to content

Commit 446e7a3

Browse files
committed
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.
1 parent 5393281 commit 446e7a3

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/evalfunc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,6 +3263,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
32633263
int save_redir_off = redir_off;
32643264
garray_T save_ga;
32653265
int save_msg_col = msg_col;
3266+
int echo_output = FALSE;
32663267

32673268
rettv->vval.v_string = NULL;
32683269
rettv->v_type = VAR_STRING;
@@ -3289,6 +3290,8 @@ f_execute(typval_T *argvars, typval_T *rettv)
32893290

32903291
if (s == NULL)
32913292
return;
3293+
if (*s == NUL)
3294+
echo_output = TRUE;
32923295
if (STRNCMP(s, "silent", 6) == 0)
32933296
++msg_silent;
32943297
if (STRCMP(s, "silent!") == 0)
@@ -3305,7 +3308,8 @@ f_execute(typval_T *argvars, typval_T *rettv)
33053308
ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
33063309
redir_execute = TRUE;
33073310
redir_off = FALSE;
3308-
msg_col = 0; // prevent leading spaces
3311+
if (!echo_output)
3312+
msg_col = 0; // prevent leading spaces
33093313

33103314
if (cmd != NULL)
33113315
do_cmdline_cmd(cmd);
@@ -3339,8 +3343,14 @@ f_execute(typval_T *argvars, typval_T *rettv)
33393343
redir_off = save_redir_off;
33403344

33413345
// "silent reg" or "silent echo x" leaves msg_col somewhere in the line.
3342-
// Put it back where it was, since nothing should have been written.
3343-
msg_col = save_msg_col;
3346+
if (echo_output)
3347+
// When not working silently: put it in column zero. A following
3348+
// "echon" will overwrite the message, unavoidably.
3349+
msg_col = 0;
3350+
else
3351+
// When working silently: Put it back where it was, since nothing
3352+
// should have been written.
3353+
msg_col = save_msg_col;
33443354
}
33453355

33463356
/*

src/testdir/test_execute_func.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,20 @@ func Test_execute_does_not_change_col()
6161
endfor
6262
call assert_equal('abcdxyz', text)
6363
endfunc
64+
65+
func Test_execute_not_silent()
66+
echo ''
67+
echon 'abcd'
68+
let x = execute('echon 234', '')
69+
echo 'xyz'
70+
let text1 = ''
71+
for col in range(1, 8)
72+
let text1 .= nr2char(screenchar(&lines - 1, col))
73+
endfor
74+
call assert_equal('abcd234 ', text1)
75+
let text2 = ''
76+
for col in range(1, 4)
77+
let text2 .= nr2char(screenchar(&lines, col))
78+
endfor
79+
call assert_equal('xyz ', text2)
80+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
571,
795797
/**/
796798
570,
797799
/**/

0 commit comments

Comments
 (0)