mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
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.
This commit is contained in:
@@ -3263,6 +3263,7 @@ f_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
int save_redir_off = redir_off;
|
int save_redir_off = redir_off;
|
||||||
garray_T save_ga;
|
garray_T save_ga;
|
||||||
int save_msg_col = msg_col;
|
int save_msg_col = msg_col;
|
||||||
|
int echo_output = FALSE;
|
||||||
|
|
||||||
rettv->vval.v_string = NULL;
|
rettv->vval.v_string = NULL;
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
@@ -3289,6 +3290,8 @@ f_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return;
|
return;
|
||||||
|
if (*s == NUL)
|
||||||
|
echo_output = TRUE;
|
||||||
if (STRNCMP(s, "silent", 6) == 0)
|
if (STRNCMP(s, "silent", 6) == 0)
|
||||||
++msg_silent;
|
++msg_silent;
|
||||||
if (STRCMP(s, "silent!") == 0)
|
if (STRCMP(s, "silent!") == 0)
|
||||||
@@ -3305,7 +3308,8 @@ f_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
|
ga_init2(&redir_execute_ga, (int)sizeof(char), 500);
|
||||||
redir_execute = TRUE;
|
redir_execute = TRUE;
|
||||||
redir_off = FALSE;
|
redir_off = FALSE;
|
||||||
msg_col = 0; // prevent leading spaces
|
if (!echo_output)
|
||||||
|
msg_col = 0; // prevent leading spaces
|
||||||
|
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
do_cmdline_cmd(cmd);
|
do_cmdline_cmd(cmd);
|
||||||
@@ -3339,8 +3343,14 @@ f_execute(typval_T *argvars, typval_T *rettv)
|
|||||||
redir_off = save_redir_off;
|
redir_off = save_redir_off;
|
||||||
|
|
||||||
// "silent reg" or "silent echo x" leaves msg_col somewhere in the line.
|
// "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.
|
if (echo_output)
|
||||||
msg_col = save_msg_col;
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -61,3 +61,20 @@ func Test_execute_does_not_change_col()
|
|||||||
endfor
|
endfor
|
||||||
call assert_equal('abcdxyz', text)
|
call assert_equal('abcdxyz', text)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_execute_not_silent()
|
||||||
|
echo ''
|
||||||
|
echon 'abcd'
|
||||||
|
let x = execute('echon 234', '')
|
||||||
|
echo 'xyz'
|
||||||
|
let text1 = ''
|
||||||
|
for col in range(1, 8)
|
||||||
|
let text1 .= nr2char(screenchar(&lines - 1, col))
|
||||||
|
endfor
|
||||||
|
call assert_equal('abcd234 ', text1)
|
||||||
|
let text2 = ''
|
||||||
|
for col in range(1, 4)
|
||||||
|
let text2 .= nr2char(screenchar(&lines, col))
|
||||||
|
endfor
|
||||||
|
call assert_equal('xyz ', text2)
|
||||||
|
endfunc
|
||||||
|
@@ -792,6 +792,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
571,
|
||||||
/**/
|
/**/
|
||||||
570,
|
570,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user