Get lines from buffers first

This commit is contained in:
Kien N 2012-04-19 17:53:45 +07:00
parent d39b7b014d
commit fa2d745b5d

View File

@ -30,17 +30,17 @@ fu! s:syntax()
endf
" Public {{{1
fu! ctrlp#line#init()
let [bufs, lines] = [filter(ctrlp#buffers(), 'filereadable(v:val)'), []]
for each in bufs
let [fnamet, ff] = [fnamemodify(each, ':t'), readfile(each)]
let bname = fnamemodify(each, ':p')
cal map(ff, 'tr(v:val, '' '', '' '')')
let [id, len_ff, bufnr] = [1, len(ff), bufnr('^'.bname.'$')]
wh id <= len_ff
let ff[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|'
let id += 1
let [bufs, lines] = [ctrlp#buffers('id'), []]
for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb
cal map(lfb, 'tr(v:val, '' '', '' '')')
let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')]
wh linenr <= len_lfb
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
let linenr += 1
endw
cal extend(lines, filter(ff, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
endfo
cal s:syntax()
retu lines