Skip to content

Commit

Permalink
Put s:byfname behind s:ispath
Browse files Browse the repository at this point in the history
Closes #421
  • Loading branch information
kien committed Jun 6, 2013
1 parent 27e2375 commit 0102255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ endf
fu! s:MatchIt(items, pat, limit, exc)
let [lines, id] = [[], 0]
let pat =
\ s:byfname ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
\ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
\ : s:martcs.a:pat
for item in a:items
let id += 1
Expand Down Expand Up @@ -511,7 +511,7 @@ fu! s:SplitPattern(str)
if exists('lst')
let pat = ''
if !empty(lst)
if s:byfname && index(lst, ';') > 0
if s:byfname() && index(lst, ';') > 0
let fbar = index(lst, ';')
let lst_1 = s:sublist(lst, 0, fbar - 1)
let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : ['']
Expand All @@ -527,7 +527,7 @@ endf
fu! s:Render(lines, pat)
let [&ma, lines, s:res_count] = [1, a:lines, len(a:lines)]
let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let cur_cmd = 'keepj norm! '.( s:mw_order == 'btt' ? 'G' : 'gg' ).'1|'
" Setup the match window
sil! exe '%d _ | res' height
Expand Down Expand Up @@ -585,7 +585,7 @@ fu! s:ForceUpdate()
endf

fu! s:BuildPrompt(upd)
let base = ( s:regexp ? 'r' : '>' ).( s:byfname ? 'd' : '>' ).'> '
let base = ( s:regexp ? 'r' : '>' ).( s:byfname() ? 'd' : '>' ).'> '
let str = escape(s:getinput(), '\')
let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy
if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp')
Expand Down Expand Up @@ -768,7 +768,7 @@ endf

fu! s:PrtSelectJump(char)
let lines = copy(s:lines)
if s:byfname
if s:byfname()
cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]')
en
" Cycle through matches, use s:jmpchr to store last jump
Expand Down Expand Up @@ -1377,7 +1377,7 @@ fu! ctrlp#statusline()
let prv = tps[s:walker(max, s:itemtype, -1)][1]
let s:ctype = tps[s:itemtype][0]
let focus = s:focus ? 'prt' : 'win'
let byfname = s:byfname ? 'file' : 'path'
let byfname = s:ispath ? s:byfname ? 'file' : 'path' : 'line'
let marked = s:opmul != '0' ?
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
if s:status != {}
Expand Down Expand Up @@ -1892,7 +1892,6 @@ endf
fu! s:modevar()
let s:matchtype = s:mtype()
let s:ispath = s:ispathitem()
if !s:ispath | let s:byfname = 0 | en
let s:mfunc = s:mfunc()
let s:nolim = s:getextvar('nolim')
let s:dosort = s:getextvar('sort')
Expand All @@ -1904,6 +1903,10 @@ fu! s:nosort()
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
endf

fu! s:byfname()
retu s:ispath && s:byfname
endf

fu! s:narrowable()
retu exists('s:act_add') && exists('s:matched') && s:matched != []
\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
Expand All @@ -1918,7 +1921,7 @@ fu! s:getinput(...)
if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k'
retu join(prt, '')
en
let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
for dict in s:abbrev['abbrevs']
let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
let pat = escape(dict['pattern'], '~')
Expand Down Expand Up @@ -2108,7 +2111,7 @@ endf

fu! s:mfunc()
let mfunc = 'match'
if s:byfname && s:ispath
if s:byfname()
let mfunc = 's:matchfname'
elsei s:itemtype > 2
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
Expand Down
2 changes: 1 addition & 1 deletion doc/ctrlp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ Highlighting:~

Statuslines:~
* Highlight groups:
CtrlPMode1 : 'file' or 'path', and the current mode (Character)
CtrlPMode1 : 'file' or 'path' or 'line', and the current mode (Character)
CtrlPMode2 : 'prt' or 'win', 'regex', the working directory (|hl-LineNr|)
CtrlPStats : the scanning status (Function)

Expand Down

0 comments on commit 0102255

Please sign in to comment.