diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-07 16:38:23 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-07 16:38:23 +0100 |
commit | 10ccaa17ec8b2be1132fd19059e1cd5fb5c902c4 (patch) | |
tree | cad997acc34535a8dce6bb52f357fd0c219314ba | |
parent | 9a8534673acd98d7398c967fe4348df63e689dab (diff) | |
download | vim-git-10ccaa17ec8b2be1132fd19059e1cd5fb5c902c4.tar.gz |
patch 8.1.0569: execute() always resets display column to zerov8.1.0569
Problem: Execute() always resets display column to zero. (Sha Liu)
Solution: Don't reset it to zero, restore the previous value. (closes #3669)
-rw-r--r-- | src/evalfunc.c | 8 | ||||
-rw-r--r-- | src/testdir/test_execute_func.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index d3bacad77..51e069981 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3262,6 +3262,7 @@ f_execute(typval_T *argvars, typval_T *rettv) int save_redir_execute = redir_execute; int save_redir_off = redir_off; garray_T save_ga; + int save_msg_col = msg_col; rettv->vval.v_string = NULL; rettv->v_type = VAR_STRING; @@ -3304,6 +3305,7 @@ f_execute(typval_T *argvars, typval_T *rettv) ga_init2(&redir_execute_ga, (int)sizeof(char), 500); redir_execute = TRUE; redir_off = FALSE; + msg_col = 0; // prevent leading spaces if (cmd != NULL) do_cmdline_cmd(cmd); @@ -3336,9 +3338,9 @@ f_execute(typval_T *argvars, typval_T *rettv) redir_execute_ga = save_ga; redir_off = save_redir_off; - /* "silent reg" or "silent echo x" leaves msg_col somewhere in the - * line. Put it back in the first column. */ - msg_col = 0; + // "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; } /* diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim index dd07e4a62..7b3cf21a5 100644 --- a/src/testdir/test_execute_func.vim +++ b/src/testdir/test_execute_func.vim @@ -49,3 +49,15 @@ func Test_execute_list() call assert_equal("", execute([])) call assert_equal("", execute(test_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 diff --git a/src/version.c b/src/version.c index eeb7cb068..312eca2cf 100644 --- a/src/version.c +++ b/src/version.c @@ -793,6 +793,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 569, +/**/ 568, /**/ 567, |