Hide the current file from the results

This commit is contained in:
Kien N 2012-03-07 07:36:46 +07:00
parent c909254257
commit ac56d68249
2 changed files with 9 additions and 12 deletions

View File

@ -310,9 +310,9 @@ endf
fu! s:Buffers() "{{{1 fu! s:Buffers() "{{{1
let allbufs = [] let allbufs = []
for each in range(1, bufnr('$')) for each in range(1, bufnr('$'))
if getbufvar(each, '&bl') && each != s:crbufnr if each != s:bufnr && getbufvar(each, '&bl')
let bufname = bufname(each) let bufname = bufname(each)
if strlen(bufname) && getbufvar(each, '&ma') && bufname != 'ControlP' if strlen(bufname) && getbufvar(each, '&ma')
cal add(allbufs, fnamemodify(bufname, ':.')) cal add(allbufs, fnamemodify(bufname, ':.'))
en en
en en
@ -320,10 +320,10 @@ fu! s:Buffers() "{{{1
retu allbufs retu allbufs
endf endf
" * MatchedItems() {{{1 " * MatchedItems() {{{1
fu! s:MatchIt(items, pat, limit, mfunc) fu! s:MatchIt(items, pat, limit, mfunc, ipt)
let newitems = [] let [newitems, crfile] = [[], exists('s:crfilerel') ? s:crfilerel : '']
for item in a:items for item in a:items
try | if call(a:mfunc, [item, a:pat]) >= 0 try | if !( a:ipt && item == crfile ) && 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
@ -332,15 +332,14 @@ fu! s:MatchIt(items, pat, limit, mfunc)
endf endf
fu! s:MatchedItems(items, pat, limit, ipt) fu! s:MatchedItems(items, pat, limit, ipt)
let [items, pat, limit, ipt] = [a:items, a:pat, a:limit, a:ipt]
let [type, mfunc] = [s:type(1), 'match'] let [type, mfunc] = [s:type(1), 'match']
if s:byfname && ipt if s:byfname && a:ipt
let mfunc = 's:matchfname' let mfunc = 's:matchfname'
elsei s:itemtype > 2 elsei s:itemtype > 2
let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
if has_key(types, type) | let mfunc = types[type] | en if has_key(types, type) | let mfunc = types[type] | en
en en
let newitems = s:MatchIt(items, pat, limit, mfunc) let newitems = s:MatchIt(a:items, a:pat, a:limit, mfunc, a:ipt)
let s:matches = len(newitems) let s:matches = len(newitems)
retu newitems retu newitems
endf endf
@ -707,7 +706,7 @@ fu! s:PrtSwitcher()
unl s:force unl s:force
endf endf
fu! s:SetWD(...) "{{{1 fu! s:SetWD(...) "{{{1
let pathmode = s:wpmode let [pathmode, s:crfilerel] = [s:wpmode, fnamemodify(s:crfile, ':.')]
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
@ -1163,6 +1162,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, ':.')
endf endf
fu! ctrlp#setlcdir() fu! ctrlp#setlcdir()

View File

@ -57,9 +57,6 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
en en
" Return the list with the active buffer removed " Return the list with the active buffer removed
if bufnr == -1 if bufnr == -1
let crf = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
let crf = exists('+ssl') ? tr(crf, '/', '\') : crf
let mrufs = empty(crf) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crf')
if s:re if s:re
let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd() let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
cal filter(mrufs, '!stridx(v:val, cwd)') cal filter(mrufs, '!stridx(v:val, cwd)')