small performance increase
This commit is contained in:
parent
7c4669c537
commit
6fd7065d9e
@ -249,12 +249,14 @@ func! s:GetMatchedItems(items, pats, limit) "{{{
|
|||||||
cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
|
cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
|
||||||
" loop through the patterns
|
" loop through the patterns
|
||||||
for each in pats
|
for each in pats
|
||||||
|
" if newitems is small, set it as items to search in
|
||||||
if exists('newitems') && len(newitems) < limit
|
if exists('newitems') && len(newitems) < limit
|
||||||
let items = newitems
|
let items = deepcopy(newitems)
|
||||||
|
let s:matcheditems = deepcopy(items)
|
||||||
endif
|
endif
|
||||||
if empty(items)
|
if empty(items) " end here
|
||||||
retu exists('newitems') ? newitems : []
|
retu exists('newitems') ? newitems : []
|
||||||
else
|
else " start here, goes back up if has 2 or more in pats
|
||||||
let newitems = []
|
let newitems = []
|
||||||
" loop through the items
|
" loop through the items
|
||||||
for item in items
|
for item in items
|
||||||
@ -391,7 +393,7 @@ func! s:Renderer(lines) "{{{
|
|||||||
cal setline('1', ' == NO MATCHES ==')
|
cal setline('1', ' == NO MATCHES ==')
|
||||||
endif
|
endif
|
||||||
" Remember selected line
|
" Remember selected line
|
||||||
if exists('g:CtrlP_cline')
|
if exists('g:CtrlP_cline') && s:pinput == 2
|
||||||
cal setpos('.', [0, g:CtrlP_cline, 1, 0])
|
cal setpos('.', [0, g:CtrlP_cline, 1, 0])
|
||||||
endif
|
endif
|
||||||
endfunc "}}}
|
endfunc "}}}
|
||||||
@ -399,11 +401,28 @@ endfunc "}}}
|
|||||||
func! s:UpdateMatches(pat) "{{{
|
func! s:UpdateMatches(pat) "{{{
|
||||||
" Delete the buffer's content
|
" Delete the buffer's content
|
||||||
sil! %d _
|
sil! %d _
|
||||||
let newpat = s:SplitPattern(a:pat)
|
let items = s:LinesFilter()
|
||||||
let lines = s:GetMatchedItems(s:lines, newpat, s:mxheight)
|
let pats = s:SplitPattern(a:pat)
|
||||||
|
let lines = s:GetMatchedItems(items, pats, s:mxheight)
|
||||||
cal s:Renderer(lines)
|
cal s:Renderer(lines)
|
||||||
endfunc "}}}
|
endfunc "}}}
|
||||||
|
|
||||||
|
func! s:LinesFilter() "{{{
|
||||||
|
" tiny performance increase, but every little bit counts
|
||||||
|
if exists('g:CtrlP_prompt_prev')
|
||||||
|
let prt = g:CtrlP_prompt
|
||||||
|
let prt_prev = g:CtrlP_prompt_prev
|
||||||
|
let str = prt[0] . prt[1] . prt[2]
|
||||||
|
let str_prev = prt_prev[0] . prt_prev[1] . prt_prev[2]
|
||||||
|
endif
|
||||||
|
if exists('s:matcheditems') && len(s:matcheditems) < s:mxheight
|
||||||
|
\ && exists('str') && match(str, str_prev) >= 0
|
||||||
|
retu s:matcheditems
|
||||||
|
else
|
||||||
|
retu s:lines
|
||||||
|
endif
|
||||||
|
endfunc "}}}
|
||||||
|
|
||||||
func! s:BuildPrompt(...) "{{{
|
func! s:BuildPrompt(...) "{{{
|
||||||
let base1 = s:regexp ? 'r' : '>'
|
let base1 = s:regexp ? 'r' : '>'
|
||||||
let base2 = s:byfname ? 'd' : '>'
|
let base2 = s:byfname ? 'd' : '>'
|
||||||
@ -448,6 +467,7 @@ endfunc
|
|||||||
|
|
||||||
func! s:PrtAdd(char)
|
func! s:PrtAdd(char)
|
||||||
let prt = g:CtrlP_prompt
|
let prt = g:CtrlP_prompt
|
||||||
|
let g:CtrlP_prompt_prev = deepcopy(g:CtrlP_prompt)
|
||||||
let prt[0] = prt[0] . a:char
|
let prt[0] = prt[0] . a:char
|
||||||
cal s:BuildPrompt()
|
cal s:BuildPrompt()
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -51,8 +51,9 @@ setting is from bottom to top: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_persistent_input'*
|
*'g:ctrlp_persistent_input'*
|
||||||
Remember the last input string and position of the selection in the match
|
Remember the last input string. Set this to 2 to also remember the last
|
||||||
window: >
|
position of the selection in the match window and 0 to completely disable this
|
||||||
|
feature: >
|
||||||
let g:ctrlp_persistent_input = 1
|
let g:ctrlp_persistent_input = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
@ -352,9 +353,10 @@ CHANGELOG
|
|||||||
|
|
||||||
*ctrlp-update-2*
|
*ctrlp-update-2*
|
||||||
Update #2~
|
Update #2~
|
||||||
|
+ Extended the behavior of |g:ctrlp_persistent_input|
|
||||||
|
+ New option: |g:ctrlp_dotfiles|
|
||||||
+ New input format: '..' (section 5.d)
|
+ New input format: '..' (section 5.d)
|
||||||
+ New mapping: <F5>.
|
+ New mapping: <F5>.
|
||||||
+ New option: |g:ctrlp_dotfiles|
|
|
||||||
+ New commands: |:CtrlPCurWD|,
|
+ New commands: |:CtrlPCurWD|,
|
||||||
|:CtrlPCurFile|,
|
|:CtrlPCurFile|,
|
||||||
|:CtrlPRoot|
|
|:CtrlPRoot|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user