diff --git a/autoload/ctrlp/line.vim b/autoload/ctrlp/line.vim index a592a41..10a45fa 100644 --- a/autoload/ctrlp/line.vim +++ b/autoload/ctrlp/line.vim @@ -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