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;
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);
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;
}
/*
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