Replace a few match() calls
This commit is contained in:
parent
9b79b74c17
commit
b3d52edb01
@ -504,7 +504,7 @@ fu! s:BuildPrompt(upd, ...)
|
|||||||
let str = join(prt, '')
|
let str = join(prt, '')
|
||||||
let lazy = empty(str) || exists('s:force') || !has('autocmd') ? 0 : s:lazy
|
let lazy = empty(str) || exists('s:force') || !has('autocmd') ? 0 : s:lazy
|
||||||
if a:upd && !lazy && ( s:matches || s:regexp
|
if a:upd && !lazy && ( s:matches || s:regexp
|
||||||
\ || match(str, '\(\\\(<\|>\)\|[*|]\)\|\(\\\:\([^:]\|\\:\)*$\)') >= 0 )
|
\ || str =~ '\(\\\(<\|>\)\|[*|]\)\|\(\\\:\([^:]\|\\:\)*$\)' )
|
||||||
sil! cal s:Update(str)
|
sil! cal s:Update(str)
|
||||||
en
|
en
|
||||||
sil! cal ctrlp#statusline()
|
sil! cal ctrlp#statusline()
|
||||||
@ -570,10 +570,10 @@ endf
|
|||||||
fu! s:PrtDeleteWord()
|
fu! s:PrtDeleteWord()
|
||||||
unl! s:hstgot
|
unl! s:hstgot
|
||||||
let [str, s:matches] = [s:prompt[0], 1]
|
let [str, s:matches] = [s:prompt[0], 1]
|
||||||
let str = match(str, '\W\w\+$') >= 0 ? matchstr(str, '^.\+\W\ze\w\+$')
|
let str = str =~ '\W\w\+$' ? matchstr(str, '^.\+\W\ze\w\+$')
|
||||||
\ : match(str, '\w\W\+$') >= 0 ? matchstr(str, '^.\+\w\ze\W\+$')
|
\ : str =~ '\w\W\+$' ? matchstr(str, '^.\+\w\ze\W\+$')
|
||||||
\ : match(str, '\s\+$') >= 0 ? matchstr(str, '^.*[^ \t]\+\ze\s\+$')
|
\ : str =~ '\s\+$' ? matchstr(str, '^.*\S\ze\s\+$')
|
||||||
\ : match(str, ' ') <= 0 ? '' : str
|
\ : str =~ '\v^(\S+|\s+)$' ? '' : str
|
||||||
let s:prompt[0] = str
|
let s:prompt[0] = str
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
endf
|
endf
|
||||||
@ -753,7 +753,7 @@ endf
|
|||||||
|
|
||||||
fu! s:MapSpecs(...)
|
fu! s:MapSpecs(...)
|
||||||
" Correct arrow keys in terminal
|
" Correct arrow keys in terminal
|
||||||
if ( has('termresponse') && match(v:termresponse, "\<ESC>") >= 0 )
|
if ( has('termresponse') && v:termresponse =~ "\<ESC>" )
|
||||||
\ || &term =~? '\vxterm|<k?vt|gnome|screen|linux'
|
\ || &term =~? '\vxterm|<k?vt|gnome|screen|linux'
|
||||||
for each in ['\A <up>','\B <down>','\C <right>','\D <left>']
|
for each in ['\A <up>','\B <down>','\C <right>','\D <left>']
|
||||||
exe s:lcmap.' <esc>['.each
|
exe s:lcmap.' <esc>['.each
|
||||||
@ -817,7 +817,7 @@ fu! s:SetWD(...)
|
|||||||
let pathmode = a:1
|
let pathmode = a:1
|
||||||
en | en
|
en | en
|
||||||
if a:0 < 2
|
if a:0 < 2
|
||||||
if match(s:crfile, '\v^<.+>://') >= 0 || !pathmode | retu | en
|
if s:crfile =~ '^.\+://' || !pathmode | retu | en
|
||||||
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
||||||
cal ctrlp#setdir(s:crfpath)
|
cal ctrlp#setdir(s:crfpath)
|
||||||
en
|
en
|
||||||
@ -1184,7 +1184,7 @@ fu! s:dircompl(be, sd)
|
|||||||
let [be, sd] = a:be == '' ? [s:dyncwd, a:sd] : [a:be, a:be.s:lash(a:be).a:sd]
|
let [be, sd] = a:be == '' ? [s:dyncwd, a:sd] : [a:be, a:be.s:lash(a:be).a:sd]
|
||||||
let dirs = ctrlp#rmbasedir(split(globpath(be, a:sd.'*/'), "\n"))
|
let dirs = ctrlp#rmbasedir(split(globpath(be, a:sd.'*/'), "\n"))
|
||||||
cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))'
|
cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))'
|
||||||
\ . ' && match(v:val, ''\v(^|[\/])\.{1,2}[\/]$'') < 0')
|
\ . ' && v:val !~ ''\v(^|[\/])\.{1,2}[\/]$''')
|
||||||
retu dirs
|
retu dirs
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -1208,7 +1208,7 @@ fu! s:headntail(str)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:lash(...)
|
fu! s:lash(...)
|
||||||
retu match(a:0 ? a:1 : s:dyncwd, '[\/]$') < 0 ? s:lash : ''
|
retu ( a:0 ? a:1 : s:dyncwd ) !~ '[\/]$' ? s:lash : ''
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:ispathitem()
|
fu! s:ispathitem()
|
||||||
@ -1221,7 +1221,7 @@ fu! ctrlp#dirnfile(entries)
|
|||||||
let etype = getftype(each)
|
let etype = getftype(each)
|
||||||
if s:igntype >= 0 && s:usrign(each, etype) | con | en
|
if s:igntype >= 0 && s:usrign(each, etype) | con | en
|
||||||
if etype == 'dir'
|
if etype == 'dir'
|
||||||
if s:dotfiles | if match(each, '[\/]\.\{1,2}$') < 0
|
if s:dotfiles | if each !~ '[\/]\.\{1,2}$'
|
||||||
cal add(items[0], each)
|
cal add(items[0], each)
|
||||||
en | el
|
en | el
|
||||||
cal add(items[0], each)
|
cal add(items[0], each)
|
||||||
@ -1254,7 +1254,7 @@ endf
|
|||||||
|
|
||||||
fu! ctrlp#rmbasedir(items)
|
fu! ctrlp#rmbasedir(items)
|
||||||
if a:items != [] && !stridx(a:items[0], s:dyncwd)
|
if a:items != [] && !stridx(a:items[0], s:dyncwd)
|
||||||
let idx = strlen(s:dyncwd) + ( match(s:dyncwd, '[\/]$') < 0 )
|
let idx = strlen(s:dyncwd) + ( s:dyncwd !~ '[\/]$' )
|
||||||
retu map(a:items, 'strpart(v:val, idx)')
|
retu map(a:items, 'strpart(v:val, idx)')
|
||||||
en
|
en
|
||||||
retu a:items
|
retu a:items
|
||||||
@ -1262,7 +1262,7 @@ endf
|
|||||||
|
|
||||||
fu! s:getparent(item)
|
fu! s:getparent(item)
|
||||||
let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '')
|
let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '')
|
||||||
if parent == '' || match(parent, '[\/]') < 0
|
if parent == '' || parent !~ '[\/]'
|
||||||
let parent .= s:lash
|
let parent .= s:lash
|
||||||
en
|
en
|
||||||
retu parent
|
retu parent
|
||||||
@ -1489,7 +1489,7 @@ endf
|
|||||||
|
|
||||||
fu! s:tail()
|
fu! s:tail()
|
||||||
if exists('s:optail') && !empty('s:optail')
|
if exists('s:optail') && !empty('s:optail')
|
||||||
let tailpref = match(s:optail, '^\s*+') < 0 ? ' +' : ' '
|
let tailpref = s:optail !~ '^\s*+' ? ' +' : ' '
|
||||||
retu tailpref.s:optail
|
retu tailpref.s:optail
|
||||||
en
|
en
|
||||||
retu ''
|
retu ''
|
||||||
@ -1500,7 +1500,7 @@ fu! s:sanstail(str)
|
|||||||
\ substitute(a:str, '^\(@.*$\|\\\\\ze@\|\.\.\zs[.\/]\+$\)', '', 'g') : a:str
|
\ substitute(a:str, '^\(@.*$\|\\\\\ze@\|\.\.\zs[.\/]\+$\)', '', 'g') : a:str
|
||||||
let [str, pat] = [substitute(str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$']
|
let [str, pat] = [substitute(str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$']
|
||||||
unl! s:optail
|
unl! s:optail
|
||||||
if match(str, '\\\@<!:'.pat) >= 0
|
if str =~ '\\\@<!:'.pat
|
||||||
let s:optail = matchstr(str, '\\\@<!:\zs'.pat)
|
let s:optail = matchstr(str, '\\\@<!:\zs'.pat)
|
||||||
let str = substitute(str, '\\\@<!:'.pat, '', '')
|
let str = substitute(str, '\\\@<!:'.pat, '', '')
|
||||||
en
|
en
|
||||||
@ -1604,7 +1604,7 @@ endf
|
|||||||
|
|
||||||
fu! s:regexfilter(str)
|
fu! s:regexfilter(str)
|
||||||
let str = a:str
|
let str = a:str
|
||||||
for key in keys(s:fpats) | if match(str, key) >= 0
|
for key in keys(s:fpats) | if str =~ key
|
||||||
let str = substitute(str, s:fpats[key], '', 'g')
|
let str = substitute(str, s:fpats[key], '', 'g')
|
||||||
en | endfo
|
en | endfo
|
||||||
retu str
|
retu str
|
||||||
|
@ -11,7 +11,7 @@ endf
|
|||||||
let s:lash = ctrlp#utils#lash()
|
let s:lash = ctrlp#utils#lash()
|
||||||
|
|
||||||
fu! s:lash(...)
|
fu! s:lash(...)
|
||||||
retu match(a:0 ? a:1 : getcwd(), '[\/]$') < 0 ? s:lash : ''
|
retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : ''
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#utils#opts()
|
fu! ctrlp#utils#opts()
|
||||||
|
@ -976,7 +976,7 @@ MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs*
|
|||||||
>
|
>
|
||||||
function! s:setcwd()
|
function! s:setcwd()
|
||||||
let cph = expand('%:p:h', 1)
|
let cph = expand('%:p:h', 1)
|
||||||
if match(cph, '\v^<.+>://') >= 0 | retu | en
|
if cph =~ '^.\+://' | retu | en
|
||||||
for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects']
|
for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects']
|
||||||
let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';'])
|
let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';'])
|
||||||
if wd != '' | let &acd = 0 | brea | en
|
if wd != '' | let &acd = 0 | brea | en
|
||||||
|
Loading…
Reference in New Issue
Block a user