From ac56d68249ed551ea21f1f0cd6d0f0dacce4fe75 Mon Sep 17 00:00:00 2001 From: Kien N Date: Wed, 7 Mar 2012 07:36:46 +0700 Subject: [PATCH] Hide the current file from the results --- autoload/ctrlp.vim | 18 +++++++++--------- autoload/ctrlp/mrufiles.vim | 3 --- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 758687d..0df2b60 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -310,9 +310,9 @@ endf fu! s:Buffers() "{{{1 let allbufs = [] for each in range(1, bufnr('$')) - if getbufvar(each, '&bl') && each != s:crbufnr + if each != s:bufnr && getbufvar(each, '&bl') let bufname = bufname(each) - if strlen(bufname) && getbufvar(each, '&ma') && bufname != 'ControlP' + if strlen(bufname) && getbufvar(each, '&ma') cal add(allbufs, fnamemodify(bufname, ':.')) en en @@ -320,10 +320,10 @@ fu! s:Buffers() "{{{1 retu allbufs endf " * MatchedItems() {{{1 -fu! s:MatchIt(items, pat, limit, mfunc) - let newitems = [] +fu! s:MatchIt(items, pat, limit, mfunc, ipt) + let [newitems, crfile] = [[], exists('s:crfilerel') ? s:crfilerel : ''] 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) en | cat | brea | endt if a:limit > 0 && len(newitems) >= a:limit | brea | en @@ -332,15 +332,14 @@ fu! s:MatchIt(items, pat, limit, mfunc) endf 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'] - if s:byfname && ipt + if s:byfname && a:ipt let mfunc = 's:matchfname' elsei s:itemtype > 2 let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } if has_key(types, type) | let mfunc = types[type] | 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) retu newitems endf @@ -707,7 +706,7 @@ fu! s:PrtSwitcher() unl s:force endf 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) cal ctrlp#setdir(a:1) | retu el @@ -1163,6 +1162,7 @@ endf fu! ctrlp#setdir(path, ...) let cmd = a:0 ? a:1 : 'lc!' sil! exe cmd ctrlp#fnesc(a:path) + let s:crfilerel = fnamemodify(s:crfile, ':.') endf fu! ctrlp#setlcdir() diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index 9fd35dd..ff485e7 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -57,9 +57,6 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1 en " Return the list with the active buffer removed 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 let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd() cal filter(mrufs, '!stridx(v:val, cwd)')