Skip to content

Commit 709d897

Browse files
committed
Find files asynchronously.
1 parent 95eb1dd commit 709d897

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

autoload/ctrlp.vim

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
9494
\ 'brief_prompt': ['s:brfprt', 0],
9595
\ 'match_current_file': ['s:matchcrfile', 0],
9696
\ 'compare_lim': ['s:compare_lim', 3000],
97+
\ 'user_command_async': ['s:usrcmdasync', 0],
9798
\ }, {
9899
\ 'open_multiple_files': 's:opmul',
99100
\ 'regexp': 's:regexp',
@@ -406,6 +407,10 @@ fu! s:GlobPath(dirs, depth)
406407
en
407408
endf
408409

410+
fu! ctrlp#addfile(ch, file)
411+
call add(g:ctrlp_allfiles, a:file)
412+
endf
413+
409414
fu! s:UserCmd(lscmd)
410415
let [path, lscmd] = [s:dyncwd, a:lscmd]
411416
let do_ign =
@@ -418,7 +423,14 @@ fu! s:UserCmd(lscmd)
418423
let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
419424
en
420425
let path = exists('*shellescape') ? shellescape(path) : path
421-
if has('patch-7.4-597') && !(has('win32') || has('win64'))
426+
if s:usrcmdasync && has('patch-7.4-1510') && exists('*job_start')
427+
let g:ctrlp_allfiles = []
428+
if has('win32') || has('win64')
429+
let s:job = job_start(printf("%s %s %s", &shell, &shellcmdflag, printf(lscmd, path)), {'callback': 'ctrlp#addfile'})
430+
else
431+
let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'})
432+
en
433+
elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
422434
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
423435
else
424436
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")

0 commit comments

Comments
 (0)