From 31627874d6a6cadfc90b6391d7341681b0ba77ef Mon Sep 17 00:00:00 2001 From: Rene Descartes Date: Mon, 5 Dec 2022 14:23:28 -0700 Subject: [PATCH] Fix immediate popup on start --- autoload/which_key.vim | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/autoload/which_key.vim b/autoload/which_key.vim index 1abc1e4..e412f69 100644 --- a/autoload/which_key.vim +++ b/autoload/which_key.vim @@ -107,24 +107,19 @@ function! which_key#start(vis, bang, prefix) " {{{ " parsed by vim-which-key itself with user defined prefix dictionary if avaliable. let s:runtime = s:create_runtime(mode, key) - if getchar(1) - while 1 - try - let c = getchar() - catch /^Vim:Interrupt$/ - return '' - endtry - if s:handle_char_on_start_is_ok(c) - return - endif - " When there are next level options, wait another timeoutlen. - " https://github.com/liuchengxu/vim-which-key/issues/3 - " https://github.com/liuchengxu/vim-which-key/issues/4 - if which_key#char_handler#wait_with_timeout() - break - endif - endwhile - endif + " When there are next level options, wait another timeoutlen. + " https://github.com/liuchengxu/vim-which-key/issues/3 + " https://github.com/liuchengxu/vim-which-key/issues/4 + while !which_key#char_handler#timeout_for_next_char() + try + let c = getchar() + catch /^Vim:Interrupt$/ + return '' + endtry + if s:handle_char_on_start_is_ok(c) + return + endif + endwhile endif let s:last_runtime_stack = [copy(s:runtime)]