Skip to content

Commit 10ccaa1

Browse files
committed
patch 8.1.0569: execute() always resets display column to zero
Problem: Execute() always resets display column to zero. (Sha Liu) Solution: Don't reset it to zero, restore the previous value. (closes #3669)
1 parent 9a85346 commit 10ccaa1

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/evalfunc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,6 +3262,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
32623262
int save_redir_execute = redir_execute;
32633263
int save_redir_off = redir_off;
32643264
garray_T save_ga;
3265+
int save_msg_col = msg_col;
32653266

32663267
rettv->vval.v_string = NULL;
32673268
rettv->v_type = VAR_STRING;
@@ -3304,6 +3305,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
33043305
ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
33053306
redir_execute = TRUE;
33063307
redir_off = FALSE;
3308+
msg_col = 0; // prevent leading spaces
33073309

33083310
if (cmd != NULL)
33093311
do_cmdline_cmd(cmd);
@@ -3336,9 +3338,9 @@ f_execute(typval_T *argvars, typval_T *rettv)
33363338
redir_execute_ga = save_ga;
33373339
redir_off = save_redir_off;
33383340

3339-
/* "silent reg" or "silent echo x" leaves msg_col somewhere in the
3340-
* line. Put it back in the first column. */
3341-
msg_col = 0;
3341+
// "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;
33423344
}
33433345

33443346
/*

src/testdir/test_execute_func.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,15 @@ func Test_execute_list()
4949
call assert_equal("", execute([]))
5050
call assert_equal("", execute(test_null_list()))
5151
endfunc
52+
53+
func Test_execute_does_not_change_col()
54+
echo ''
55+
echon 'abcd'
56+
let x = execute('silent echo 234343')
57+
echon 'xyz'
58+
let text = ''
59+
for col in range(1, 7)
60+
let text .= nr2char(screenchar(&lines, col))
61+
endfor
62+
call assert_equal('abcdxyz', text)
63+
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+
569,
795797
/**/
796798
568,
797799
/**/

0 commit comments

Comments
 (0)