mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1425: execute() does not work in completion of user command (#9317)
Problem: execute() does not work in completion of user command. (thinca)
Solution: Switch off redir_off and restore it. (Ozaki Kiichi, closes vim/vim#2492)
2095148277
This commit is contained in:
parent
77b5e9ae25
commit
7697628345
@ -8125,6 +8125,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
const int save_msg_silent = msg_silent;
|
const int save_msg_silent = msg_silent;
|
||||||
const int save_emsg_silent = emsg_silent;
|
const int save_emsg_silent = emsg_silent;
|
||||||
const bool save_emsg_noredir = emsg_noredir;
|
const bool save_emsg_noredir = emsg_noredir;
|
||||||
|
const bool save_redir_off = redir_off;
|
||||||
garray_T *const save_capture_ga = capture_ga;
|
garray_T *const save_capture_ga = capture_ga;
|
||||||
|
|
||||||
if (check_secure()) {
|
if (check_secure()) {
|
||||||
@ -8152,6 +8153,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
garray_T capture_local;
|
garray_T capture_local;
|
||||||
ga_init(&capture_local, (int)sizeof(char), 80);
|
ga_init(&capture_local, (int)sizeof(char), 80);
|
||||||
capture_ga = &capture_local;
|
capture_ga = &capture_local;
|
||||||
|
redir_off = false;
|
||||||
|
|
||||||
if (argvars[0].v_type != VAR_LIST) {
|
if (argvars[0].v_type != VAR_LIST) {
|
||||||
do_cmdline_cmd(tv_get_string(&argvars[0]));
|
do_cmdline_cmd(tv_get_string(&argvars[0]));
|
||||||
@ -8169,6 +8171,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
msg_silent = save_msg_silent;
|
msg_silent = save_msg_silent;
|
||||||
emsg_silent = save_emsg_silent;
|
emsg_silent = save_emsg_silent;
|
||||||
emsg_noredir = save_emsg_noredir;
|
emsg_noredir = save_emsg_noredir;
|
||||||
|
redir_off = save_redir_off;
|
||||||
|
|
||||||
ga_append(capture_ga, NUL);
|
ga_append(capture_ga, NUL);
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
|
@ -206,3 +206,15 @@ func Test_CmdCompletion()
|
|||||||
com! -complete=customlist,CustomComp DoCmd :
|
com! -complete=customlist,CustomComp DoCmd :
|
||||||
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
|
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func CallExecute(A, L, P)
|
||||||
|
" Drop first '\n'
|
||||||
|
return execute('echo "hi"')[1:]
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_use_execute_in_completion()
|
||||||
|
command! -nargs=* -complete=custom,CallExecute DoExec :
|
||||||
|
call feedkeys(":DoExec \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
|
call assert_equal('"DoExec hi', @:)
|
||||||
|
delcommand DoExec
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user