From 8de5d641691a0d7e29759c5f0fe54875acab124b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 8 Dec 2018 14:05:07 -0500 Subject: 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) https://github.com/vim/vim/commit/10ccaa17ec8b2be1132fd19059e1cd5fb5c902c4 --- src/nvim/eval.c | 5 +++++ src/nvim/testdir/test_execute_func.vim | 12 ++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1640729c94..f721d398c6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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; diff --git a/src/nvim/testdir/test_execute_func.vim b/src/nvim/testdir/test_execute_func.vim index 6f61bede93..e474e0ce36 100644 --- a/src/nvim/testdir/test_execute_func.vim +++ b/src/nvim/testdir/test_execute_func.vim @@ -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 -- cgit From 7443da6f6e819cbe0c4432a44a596de54c64b3d8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 9 Dec 2018 08:33:11 -0500 Subject: vim-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. https://github.com/vim/vim/commit/446e7a3cd36b2de7d559f167eb5795d1e1cd3ddb --- src/nvim/eval.c | 19 ++++++++++++++++--- src/nvim/testdir/test_execute_func.vim | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f721d398c6..a4606f76f3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8332,6 +8332,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) const bool save_redir_off = redir_off; garray_T *const save_capture_ga = capture_ga; const int save_msg_col = msg_col; + bool echo_output = false; if (check_secure()) { return; @@ -8344,6 +8345,9 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (s == NULL) { return; } + if (*s == NUL) { + echo_output = true; + } if (strncmp(s, "silent", 6) == 0) { msg_silent++; } @@ -8359,7 +8363,9 @@ 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 (!echo_output) { + msg_col = 0; // prevent leading spaces + } if (argvars[0].v_type != VAR_LIST) { do_cmdline_cmd(tv_get_string(&argvars[0])); @@ -8379,8 +8385,15 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) 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; + if (echo_output) { + // 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; + } ga_append(capture_ga, NUL); rettv->v_type = VAR_STRING; diff --git a/src/nvim/testdir/test_execute_func.vim b/src/nvim/testdir/test_execute_func.vim index e474e0ce36..eb84a6739d 100644 --- a/src/nvim/testdir/test_execute_func.vim +++ b/src/nvim/testdir/test_execute_func.vim @@ -65,3 +65,20 @@ func Test_execute_does_not_change_col() endfor call assert_equal('abcdxyz', text) 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 -- cgit From 559401ebe57340fc7fa48ae7dffdf4fa9ddaa6d1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 4 Feb 2019 22:53:03 -0500 Subject: oldtests: set laststatus=1 --- src/nvim/testdir/setup.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index 011433f19e..c75b00d5de 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -16,6 +16,7 @@ set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd set listchars=eol:$ set fillchars=vert:\|,fold:- set shortmess-=F +set laststatus=1 " Prevent Nvim log from writing to stderr. let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' -- cgit