Skip to content

Commit 04e7cbf

Browse files
committed
use timer for command that change screen
1 parent 8c96b6f commit 04e7cbf

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

autoload/nvim/api.vim

+15-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ EOF
213213
endfunction
214214

215215
function! s:funcs.command(command) abort
216-
execute a:command
216+
" command that could cause cursor vanish
217+
if a:command =~# '^echo' || a:command =~# '^redraws' || a:command =~# '^sign place'
218+
call timer_start(0, {-> s:execute(a:command)})
219+
else
220+
execute a:command
221+
endif
217222
endfunction
218223

219224
function! s:funcs.set_current_dir(dir) abort
@@ -313,7 +318,7 @@ function! s:funcs.call_atomic(calls)
313318
elseif key ==# 'nvim_call_dict_function'
314319
call call(arglist[1], arglist[2], arglist[0])
315320
elseif key ==# 'nvim_command'
316-
execute arglist[0]
321+
call s:funcs.command(arglist[0])
317322
elseif key ==# 'nvim_eval'
318323
call eval(arglist[0])
319324
elseif key ==# 'nvim_buf_set_var'
@@ -382,5 +387,13 @@ function! nvim#api#call(native, method, ...) abort
382387
return [err, res]
383388
endfunction
384389

390+
function! s:execute(cmd)
391+
if a:cmd =~# '^echo'
392+
execute a:cmd
393+
else
394+
silent! execute a:cmd
395+
endif
396+
endfunction
397+
385398
let &cpo = s:save_cpo
386399
unlet s:save_cpo

0 commit comments

Comments
 (0)