mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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 vim/vim#3669)
10ccaa17ec
This commit is contained in:
parent
f046f3a239
commit
8de5d64169
@ -8331,6 +8331,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
const bool save_emsg_noredir = emsg_noredir;
|
||||
const bool save_redir_off = redir_off;
|
||||
garray_T *const save_capture_ga = capture_ga;
|
||||
const int save_msg_col = msg_col;
|
||||
|
||||
if (check_secure()) {
|
||||
return;
|
||||
@ -8358,6 +8359,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
ga_init(&capture_local, (int)sizeof(char), 80);
|
||||
capture_ga = &capture_local;
|
||||
redir_off = false;
|
||||
msg_col = 0; // prevent leading spaces
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST) {
|
||||
do_cmdline_cmd(tv_get_string(&argvars[0]));
|
||||
@ -8376,6 +8378,9 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
emsg_silent = save_emsg_silent;
|
||||
emsg_noredir = save_emsg_noredir;
|
||||
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;
|
||||
|
||||
ga_append(capture_ga, NUL);
|
||||
rettv->v_type = VAR_STRING;
|
||||
|
@ -53,3 +53,15 @@ func Test_execute_list()
|
||||
call assert_equal("", execute([]))
|
||||
call assert_equal("", execute(v:_null_list))
|
||||
endfunc
|
||||
|
||||
func Test_execute_does_not_change_col()
|
||||
echo ''
|
||||
echon 'abcd'
|
||||
let x = execute('silent echo 234343')
|
||||
echon 'xyz'
|
||||
let text = ''
|
||||
for col in range(1, 7)
|
||||
let text .= nr2char(screenchar(&lines, col))
|
||||
endfor
|
||||
call assert_equal('abcdxyz', text)
|
||||
endfunc
|
||||
|
Loading…
Reference in New Issue
Block a user