ctrlpvim / ctrlp.vim

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
ctrlpvim.github.com/ctrlp.vim
Other
5.55k stars 260 forks source link

Is there a limit to the number of files scanned when using user command? #600

Closed ydzhou closed 2 years ago

ydzhou commented 2 years ago

My CtrlP setup to use fd to scan files.

When I search vimrc in my home directory, those more unrelated results show up but not the actual dotfiles/vim/vimrc

>   Downloads/Iosevka/Iosevka Term Bold Nerd Font Complete Mono.ttf
>   Downloads/Iosevka/Iosevka Term Oblique Nerd Font Complete.ttf
>   Downloads/Iosevka/Iosevka Medium Nerd Font Complete Mono.ttf
>   Downloads/Iosevka/Iosevka Term Medium Nerd Font Complete.ttf
>   Downloads/Iosevka/Iosevka Term Light Nerd Font Complete.ttf

Here is my setup

let g:ctrlp_map = '<leader>/'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = {
            \ 'dir': '\.git$\|\.hg$\|\.svn$\|Library$\|Applications$\|Movies$\|Pictures$\|Music$\|tmp$',
            \ 'file': '\.zip$\|\.so$\|\.o$\|\.obj$\|\.class$\|\.DS_Store$'
            \}
let g:ctrlp_match_window = 'bottom,order:btt,min:5,max:30,results:30'
if executable('fd')
    let g:ctrlp_user_command = 'fd --type f --color never "" %s'
endif
let g:webdevicons_enable_ctrlp = 1
let g:ctrlp_by_filename = 0
let g:ctrlp_use_caching = 0
let g:ctrlp_mruf_max = 0
let g:ctrlp_max_files = 0
let g:ctrlp_max_depth = 20
let g:ctrlp_user_command_async = 1

If I do not use user command fd to scan, it works. If I use fd but change settings on g:ctrlp_match_window to be bottom,order:btt,min:5,max:30,results:2000, it also works.

That's why I am wondering if there is a limit on how many scanned files CtrlP can read from an external scanner. Do you have any thought?

mattn commented 2 years ago

As far as I can see the code, using g:ctrlp_user_command have limits specified by g:ctrlp_max_files

ydzhou commented 2 years ago

Interesting. If file is not loaded due to limit of g:ctrlp_max_files, why can I see them if I keep typing more characters?

mattn commented 2 years ago

rendering become heavily when too many files given. So I added code to omit lines over the limit. So you can get matched item if you type some.

ydzhou commented 2 years ago

Can you point me to the code? How do you think about making this as an option? I can help with the code change.

mattn commented 2 years ago

https://github.com/ctrlpvim/ctrlp.vim/commit/628958ecb21046706c108d5a1aa2cc320438bf25

ydzhou commented 2 years ago

I think I find out the root cause why more relevant files are shown up. Can you take a look at the PR?

ydzhou commented 2 years ago

Looks like the root cause is actually the performance of fuzzy matcher... Maybe this is a constraint of vimscript.

Every new character you type requires a re-run of fuzzy matcher on all the files and it is performance draining. So current code exists the matching if it "find" enough. But "found" one might no be the best candidate... This problem is harder than I thought 🤔

mattn commented 2 years ago

closable?

ydzhou commented 2 years ago

Yeah please