Skip to content

Commit

Permalink
Merge pull request ctrlpvim#595 from ctrlpvim/optimize4
Browse files Browse the repository at this point in the history
Optimize s:pathshorten()
  • Loading branch information
mattn authored Mar 16, 2022
2 parents 3b488a5 + f75c329 commit acbff25
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1764,16 +1764,22 @@ fu! s:formatline2(ct, key, str)
let str .= printf(' %s', parts[3])
en
en
retu s:lineprefix.str
en
let cond = a:ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
let cond = s:ispath && ( s:winw - 4 ) < strchars(str)
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
endf


fu! s:pathshorten(str)
retu matchstr(a:str, '^.\{9}').'...'
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
endf
if exists('*strchars') && exists('*strcharpart')
fu! s:pathshorten(str)
retu strcharpart(a:str, 0, 9).'...'.strcharpart(a:str, strchars(a:str) - s:winw + 16)
endf
el
fu! s:pathshorten(str)
retu matchstr(a:str, '^.\{9}').'...'
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
endf
en

fu! s:offset(lines, height)
let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0
Expand Down

0 comments on commit acbff25

Please sign in to comment.