Merge branch 'narrowing'
This commit is contained in:
commit
17f697a1cb
@ -316,13 +316,16 @@ fu! ctrlp#buffers()
|
|||||||
endf
|
endf
|
||||||
" * MatchedItems() {{{1
|
" * MatchedItems() {{{1
|
||||||
fu! s:MatchIt(items, pat, limit, mfunc, ipt, exc)
|
fu! s:MatchIt(items, pat, limit, mfunc, ipt, exc)
|
||||||
let newitems = []
|
let [newitems, id, itlen] = [[], 0, len(a:items)]
|
||||||
for item in a:items
|
wh id < itlen
|
||||||
|
let item = a:items[id]
|
||||||
|
let id += 1
|
||||||
try | if !( a:ipt && item == a:exc ) && call(a:mfunc, [item, a:pat]) >= 0
|
try | if !( a:ipt && item == a:exc ) && call(a:mfunc, [item, a:pat]) >= 0
|
||||||
cal add(newitems, item)
|
cal add(newitems, item)
|
||||||
en | cat | brea | endt
|
en | cat | brea | endt
|
||||||
if a:limit > 0 && len(newitems) >= a:limit | brea | en
|
if a:limit > 0 && len(newitems) >= a:limit | brea | en
|
||||||
endfo
|
endw
|
||||||
|
let s:mdata = [s:dyncwd, s:itemtype, s:regexp, a:items[(id):]]
|
||||||
retu newitems
|
retu newitems
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -336,7 +339,8 @@ fu! s:MatchedItems(items, str, pat, limit, ipt)
|
|||||||
en
|
en
|
||||||
let exc = exists('s:crfilerel') ? s:crfilerel : ''
|
let exc = exists('s:crfilerel') ? s:crfilerel : ''
|
||||||
let matfunc = 's:MatchIt'
|
let matfunc = 's:MatchIt'
|
||||||
let argms = [a:items, a:pat, a:limit, mfunc, a:ipt, exc]
|
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
|
||||||
|
let argms = [items, a:pat, a:limit, mfunc, a:ipt, exc]
|
||||||
if s:matcher != {} && has_key(s:matcher, 'match')
|
if s:matcher != {} && has_key(s:matcher, 'match')
|
||||||
let [matfunc, argms[1], argms[3]] = s:matargs(mfunc, a:str)
|
let [matfunc, argms[1], argms[3]] = s:matargs(mfunc, a:str)
|
||||||
let argms += [s:regexp]
|
let argms += [s:regexp]
|
||||||
@ -387,9 +391,8 @@ fu! s:Render(lines, pat, ipt)
|
|||||||
if s:dohighlight() | cal clearmatches() | en
|
if s:dohighlight() | cal clearmatches() | en
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
" Sort if not MRU
|
if ( ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') )
|
||||||
if ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') )
|
\ || s:prompt != ['', '', ''] ) && s:matcher == {}
|
||||||
\ || s:prompt != ['', '', '']
|
|
||||||
let s:compat = a:pat
|
let s:compat = a:pat
|
||||||
cal sort(lines, 's:mixedsort')
|
cal sort(lines, 's:mixedsort')
|
||||||
unl s:compat
|
unl s:compat
|
||||||
@ -467,8 +470,10 @@ endf
|
|||||||
|
|
||||||
fu! s:PrtAdd(char)
|
fu! s:PrtAdd(char)
|
||||||
unl! s:hstgot
|
unl! s:hstgot
|
||||||
|
let s:act_add = 1
|
||||||
let s:prompt[0] .= a:char
|
let s:prompt[0] .= a:char
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
|
unl s:act_add
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:PrtBS()
|
fu! s:PrtBS()
|
||||||
@ -708,7 +713,8 @@ fu! s:PrtSwitcher()
|
|||||||
unl s:force
|
unl s:force
|
||||||
endf
|
endf
|
||||||
fu! s:SetWD(...) "{{{1
|
fu! s:SetWD(...) "{{{1
|
||||||
let [pathmode, s:crfilerel] = [s:wpmode, fnamemodify(s:crfile, ':.')]
|
let pathmode = s:wpmode
|
||||||
|
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
|
||||||
if a:0 && strlen(a:1) | if type(a:1)
|
if a:0 && strlen(a:1) | if type(a:1)
|
||||||
cal ctrlp#setdir(a:1) | retu
|
cal ctrlp#setdir(a:1) | retu
|
||||||
el
|
el
|
||||||
@ -1165,7 +1171,7 @@ endf
|
|||||||
fu! ctrlp#setdir(path, ...)
|
fu! ctrlp#setdir(path, ...)
|
||||||
let cmd = a:0 ? a:1 : 'lc!'
|
let cmd = a:0 ? a:1 : 'lc!'
|
||||||
sil! exe cmd ctrlp#fnesc(a:path)
|
sil! exe cmd ctrlp#fnesc(a:path)
|
||||||
let s:crfilerel = fnamemodify(s:crfile, ':.')
|
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#setlcdir()
|
fu! ctrlp#setlcdir()
|
||||||
@ -1352,6 +1358,12 @@ fu! s:argmaps(md, ...)
|
|||||||
retu a:md
|
retu a:md
|
||||||
endf
|
endf
|
||||||
" Misc {{{2
|
" Misc {{{2
|
||||||
|
fu! s:narrowable()
|
||||||
|
retu exists('s:act_add') && exists('s:matched') && s:matched != []
|
||||||
|
\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
|
||||||
|
\ && s:matcher == {}
|
||||||
|
endf
|
||||||
|
|
||||||
fu! s:matargs(mfunc, str)
|
fu! s:matargs(mfunc, str)
|
||||||
let match_type = {
|
let match_type = {
|
||||||
\ 'match': 'full-line',
|
\ 'match': 'full-line',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user