ctrlpvim / ctrlp.vim

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

find file prompt slows down enormously when there are no matches #574

Open vcc-huf opened 2 years ago

vcc-huf commented 2 years ago

using the latest version from git, with these settings: let g:ctrlp_cmd = 'CtrlPBuffer' let g:ctrlp_regexp = 1 let g:ctrlp_max_files=0 let g:ctrlp_use_caching = 1

in the "files" search buffer, the speed is perfectly fine until i make a typo and there are no matches. at this point, typing backspace to correct the typo takes ages. about one backspace per second.

once i've deleted enough characters to once again have at least one match, it's suddenly fast again.

vcc-huf commented 2 years ago

not knowingmuch vimscript, this seems to improve it, but i'm 100% sure it's buggy as hell:

diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index c8f5e1b..dd7f10a 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -646,6 +646,9 @@ fu! s:MatchIt(items, pat, limit, exc)
        let pat =
                \ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
                \ : s:martcs.a:pat
+    if empty(s:matched) && len(pat) > len(s:ppat)
+        return lines
+    en
        for item in a:items
                let id += 1
                try
@@ -657,6 +660,9 @@ fu! s:MatchIt(items, pat, limit, exc)
                if a:limit > 0 && len(lines) >= a:limit | brea | en
        endfo
        let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]
+    if !empty(lines)
+        let s:ppat = pat
+    en
        retu lines
 endf