Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vcc-huf opened this issue Sep 16, 2021 · 1 comment
Open

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

vcc-huf opened this issue Sep 16, 2021 · 1 comment

Comments

@vcc-huf
Copy link

vcc-huf commented Sep 16, 2021

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
Copy link
Author

vcc-huf commented Sep 16, 2021

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
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant