diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 6d17d99..fcf8f46 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -316,10 +316,10 @@ fu! s:lsCmd() en endf " - Buffers {{{1 -fu! ctrlp#buffers() - retu map(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' - \ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))'), - \ 'fnamemodify(bufname(v:val), ":.")') +fu! ctrlp#buffers(...) + let ids = filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' + \ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))') + retu a:0 && a:1 == 'id' ? ids : map(ids, 'fnamemodify(bufname(v:val), ":.")') endf " * MatchedItems() {{{1 fu! s:MatchIt(items, pat, limit, exc) diff --git a/autoload/ctrlp/changes.vim b/autoload/ctrlp/changes.vim index 0e78cce..0b48689 100644 --- a/autoload/ctrlp/changes.vim +++ b/autoload/ctrlp/changes.vim @@ -52,17 +52,14 @@ fu! s:syntax() endf " Public {{{1 fu! ctrlp#changes#init(original_bufnr, fname) - let fname = exists('s:bufname') ? s:bufname : a:fname - let bufs = exists('s:clmode') && s:clmode - \ ? filter(ctrlp#buffers(), 'filereadable(v:val)') : [fname] + let bufnr = exists('s:bufnr') ? s:bufnr : bufnr('^'.a:fname.'$') + let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr] + cal filter(bufs, 'v:val > 0') let [swb, &swb] = [&swb, ''] let lines = [] for each in bufs - let [bname, fnamet] = [fnamemodify(each, ':p'), fnamemodify(each, ':t')] - let bufnr = bufnr('^'.bname.'$') - if bufnr > 0 - cal extend(lines, s:process(s:changelist(bufnr), bufnr, fnamet)) - en + let fnamet = fnamemodify(bufname(each), ':t') + cal extend(lines, s:process(s:changelist(each), each, fnamet)) endfo sil! exe 'noa hid b' a:original_bufnr let &swb = swb @@ -85,13 +82,13 @@ endf fu! ctrlp#changes#cmd(mode, ...) let s:clmode = a:mode if a:0 && !empty(a:1) - let s:bufname = fnamemodify(a:1, ':p') + let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$') en retu s:id endf fu! ctrlp#changes#exit() - unl! s:clmode s:bufname + unl! s:clmode s:bufnr endf "}}} diff --git a/autoload/ctrlp/mixed.vim b/autoload/ctrlp/mixed.vim index 065a847..cf01d10 100644 --- a/autoload/ctrlp/mixed.vim +++ b/autoload/ctrlp/mixed.vim @@ -27,7 +27,7 @@ fu! s:newcache(cwd) retu g:ctrlp_allmixes['cwd'] != a:cwd \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile()) \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile()) - \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#mrufs()) + \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs()) endf fu! s:getnewmix(cwd, clim) @@ -41,6 +41,8 @@ fu! s:getnewmix(cwd, clim) if exists('+ssl') && &ssl cal map(mrufs, 'tr(v:val, "\\", "/")') en + let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")') + let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0') if len(mrufs) > len(g:ctrlp_lines) cal filter(mrufs, 'stridx(v:val, a:cwd)') el @@ -59,7 +61,7 @@ fu! s:getnewmix(cwd, clim) en let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()), \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd, - \ 'bufs': len(ctrlp#mrufiles#mrufs()), 'data': g:ctrlp_lines } + \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines } endf " Public {{{1 fu! ctrlp#mixed#init(clim) diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index 72b6e3f..4b0ddb7 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -25,12 +25,11 @@ fu! s:excl(fn) retu !empty(s:ex) && a:fn =~# s:ex endf -fu! s:mergelists(...) +fu! s:mergelists() let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile()) - let mrus = a:0 && a:1 == 'raw' ? s:mrbs : s:mrufs - cal filter(diskmrufs, 'index(mrus, v:val) < 0') - let mrua = mrus + diskmrufs - retu a:0 && a:1 == 'raw' ? mrua : s:chop(mrua) + cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0') + let mrufs = s:mrufs + diskmrufs + retu s:chop(mrufs) endf fu! s:chop(mrufs) @@ -54,15 +53,13 @@ fu! s:record(bufnr) if empty(bufname) | retu | en let fn = fnamemodify(bufname, ':p') let fn = exists('+ssl') ? tr(fn, '/', '\') : fn - if empty(fn) || !empty(&bt) | retu | en cal filter(s:mrbs, 'v:val !='.s:csen.' fn') cal insert(s:mrbs, fn) if ( !empty(s:in) && fn !~# s:in ) || ( !empty(s:ex) && fn =~# s:ex ) - \ || !filereadable(fn) | retu + \ || !empty(&bt) || !filereadable(fn) | retu en cal filter(s:mrufs, 'v:val !='.s:csen.' fn') cal insert(s:mrufs, fn) - let s:mrufs = s:chop(s:mrufs) endf fu! s:savetofile(mrufs) @@ -91,17 +88,13 @@ fu! ctrlp#mrufiles#remove(files) endf fu! ctrlp#mrufiles#list(...) - retu a:0 ? a:1 == 'raw' ? s:mergelists(a:1) : 0 : s:reformat(s:mergelists()) + retu a:0 ? a:1 == 'raw' ? s:mergelists() : 0 : s:reformat(s:mergelists()) endf fu! ctrlp#mrufiles#bufs() retu s:mrbs endf -fu! ctrlp#mrufiles#mrufs() - retu s:mrufs -endf - fu! ctrlp#mrufiles#cachefile() if !exists('s:cadir') || !exists('s:cafile') let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'