g:clap_popup_input_delay = 0 still have delay time
bbchung opened this issue · 8 comments
Instructions: Replace the template text and remove irrelevant text (including this line)
Warning: if you don't fill this issue template and provide the reproducible steps the issue could be closed directly.
Environment (please complete the following information):
- OS: ubuntu 22.04 on wsl
- (Neo)Vim version: 9(1-1672)
- vim-clap version: 710c0dc
- Have you reproduced with a minimal vimrc: no
- Have you updated to the latest plugin version: yes
- Have you upgraded to/compiled the latest Rust binary: yes
To Reproduce
let g:clap_popup_input_delay = 0 in .vimrc
:Clap files
type somethings in Clap ui and it's easy to feel there is still have delay time
I'm unsure what kind of delay you are referring to, it works fine on my side. Does it work before and happens lately or it's your first time to use vim-clap? Also, please post the info of :Clap debug
for a bug report.
To have a better understanding of what happened, create a config.toml according to your system https://github.com/liuchengxu/vim-clap#config-file, add the log option:
[log]
log-file = "/tmp/clap.log"
max-level = "debug"
Open vim and run :Clap files
, input some query and check out the log. You'll see something like this, ensure the backend is good.
2023-07-04T00:25:33.816101Z DEBUG maple_core::searcher::files: 131: Searching is complete in 7ms total_processed=814 total_matched=800 query="s"
2023-07-04T00:25:33.917826Z DEBUG maple_core::searcher::files: 131: Searching is complete in 9ms total_processed=814 total_matched=791 query="sr"
2023-07-04T00:25:33.990836Z DEBUG maple_core::searcher::files: 131: Searching is complete in 7ms total_processed=814 total_matched=617 query="srl"
2023-07-04T00:25:34.117611Z DEBUG maple_core::searcher::files: 131: Searching is complete in 5ms total_processed=814 total_matched=268 query="srli"
If the backend is fine, change max-level = "debug"
to max-level = "trace"
, delete "/tmp.clap.log". Close and re-open Vim, :Clap files
and input some query, exit Vim, and upload the log file.
This "delay" is "g:clap_popup_input_delay", and it should be a "frontend" delay. The searching should be start "immediately" after keying 1 char when set this option to 0, but it not, the searching start after about 0.1 second when I stop keying, does it meet expectation?(searching is fast)
No, if it's 0, the query should be sent to the backend immediately.
vim-clap/autoload/clap/popup/move_manager.vim
Line 258 in 710c0dc
BTW, how do you know it's a delay of 0.1s right after typing a char?
btw above situation does not happen on another plugin https://github.com/Yggdroot/LeaderF
I see, there is a debounce of 200ms by default
Try this patch and see if it helps.
diff --git a/autoload/clap/client.vim b/autoload/clap/client.vim
index adec0fb..a322d28 100644
--- a/autoload/clap/client.vim
+++ b/autoload/clap/client.vim
@@ -88,7 +88,7 @@ function! clap#client#notify_on_init(...) abort
\ 'display': { 'bufnr': g:clap.display.bufnr, 'winid': g:clap.display.winid },
\ 'cwd': clap#rooter#working_dir(),
\ 'icon': g:clap_enable_icon ? get(g:clap.provider._(), 'icon', 'Null') : 'Null',
- \ 'debounce': get(g:clap.provider._(), 'debounce', v:true),
+ \ 'debounce': get(g:clap.provider._(), 'debounce', v:false),
\ 'no_cache': has_key(g:clap.context, 'no-cache') ? v:true : v:false,
\ 'start_buffer_path': expand('#'.g:clap.start.bufnr.':p'),
\ }
If this is the reason, we can make it configurable so that people can decide on their own.
It solve issue, thanks! Feel alot faster to set debounce to false
In #993, you can configure the debounce using the config file https://github.com/liuchengxu/vim-clap#config-file. Note that the debounce is pretty beneficial when you work with an enormous amount of results (dozens of millions), but it's indeed more responsive when the data reset is not huge without the debounce.
[provider.debounce]
# Change the debounce delay to 150ms for all providers, the default is 200ms
"*" = 150
# Change the debounce delay to 0ms for files provider specifically.
"files" = 0