Skip to content

Commit fd1534c

Browse files
committed
Merge branch 'asynchronized'
2 parents c6d1fc5 + 2a92396 commit fd1534c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

autoload/ctrlp.vim

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
9898
\ 'bufname_mod': ['s:bufname_mod', ':t'],
9999
\ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
100100
\ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'],
101+
\ 'user_command_async': ['s:usrcmdasync', 0],
101102
\ }, {
102103
\ 'open_multiple_files': 's:opmul',
103104
\ 'regexp': 's:regexp',
@@ -433,6 +434,11 @@ fu! s:GlobPath(dirs, depth)
433434
en
434435
endf
435436

437+
fu! ctrlp#addfile(ch, file)
438+
call add(g:ctrlp_allfiles, a:file)
439+
cal s:BuildPrompt(1)
440+
endf
441+
436442
fu! s:UserCmd(lscmd)
437443
let [path, lscmd] = [s:dyncwd, a:lscmd]
438444
let do_ign =
@@ -448,7 +454,13 @@ fu! s:UserCmd(lscmd)
448454
if (has('win32') || has('win64')) && match(&shell, 'sh') != -1
449455
let path = tr(path, '\', '/')
450456
en
451-
if has('patch-7.4-597') && !(has('win32') || has('win64'))
457+
if s:usrcmdasync && v:version >= 800 && exists('*job_start')
458+
if exists('s:job')
459+
call job_stop(s:job)
460+
en
461+
let g:ctrlp_allfiles = []
462+
let s:job = job_start(printf(lscmd, path), {'callback': 'ctrlp#addfile'})
463+
elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
452464
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
453465
el
454466
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
@@ -660,7 +672,7 @@ fu! s:Update(str)
660672
let pat = s:matcher == {} ? s:SplitPattern(str) : str
661673
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
662674
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
663-
if empty(str) | call clearmatches() | en
675+
if empty(str) | cal clearmatches() | en
664676
cal s:Render(lines, pat)
665677
return lines
666678
endf

0 commit comments

Comments
 (0)