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

bug: g_ctrlp_extensons execution priority is too low #617

Open q962 opened 1 year ago

q962 commented 1 year ago

https://github.com/ctrlpvim/ctrlp.vim/blob/8b4a9523632049b3b373de1233bef346073b8982/autoload/ctrlp.vim#L231-L233

What is obtained here is s:usrign, but the filtering function is realized through a g:ctrlp_custom_ignore (alias s:usrign).

The autoignore.vim extension modifies g:ctrlp_custom_ignore https://github.com/ctrlpvim/ctrlp.vim/blob/8b4a9523632049b3b373de1233bef346073b8982/autoload/ctrlp.vim#L274-L279

s:usrign has already used the default value, and it is too late to wait for autoignore.vim to modify g:ctrlp_custom_ignore.

To call the autoignore function requires three operations, which is too cumbersome


What happens if you increase the execution priority of an extension?

patch

diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index 600ffa2..bb4512d 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -228,6 +228,16 @@ fu! s:opts(...)
    for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each)
        let {each} = s:{each}
    en | endfo
+
+   " Extensions
+   let key="extensions"
+   let s:{key} = exists(s:pref.key) ? {s:pref.key} : s:opts[key][1]
+   if ! exists('extensions')
+       for each in s:extensions
+           exe 'ru autoload/ctrlp/'.each.'.vim'
+       endfo
+   en
+
    for [ke, va] in items(s:opts)
        let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
    endfo
@@ -271,12 +281,6 @@ fu! s:opts(...)
    if s:lazy
        cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
    en
-   " Extensions
-   if !( exists('extensions') && extensions == s:extensions )
-       for each in s:extensions
-           exe 'ru autoload/ctrlp/'.each.'.vim'
-       endfo
-   en
    " Keymaps
    if type(s:urprtmaps) == 4
        cal extend(s:prtmaps, s:urprtmaps)
@@ -551,7 +555,7 @@ fu! s:UserCmd(lscmd)
        let argv = [&shell, &shellcmdflag, printf(lscmd, path)]
        if !has('nvim')
            let s:job = job_start(argv, {
-                       \ 'out_cb': function('s:async_glob_on_stdout'), 
+                       \ 'out_cb': function('s:async_glob_on_stdout'),
                        \ 'exit_cb': function('s:async_glob_on_exit')
                        \ })
        el