Add a max results setting

This commit is contained in:
Kien N 2013-07-24 17:58:24 +07:00
parent aa026c0b37
commit 6e4fb3b45f
2 changed files with 9 additions and 2 deletions

View File

@ -259,6 +259,10 @@ fu! s:match_window_opts()
\ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
let s:mw_min = min([s:mw_min, s:mw_max])
let s:mw_res =
\ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+'))
\ : min([s:mw_max, &lines])
let s:mw_res = max([s:mw_res, 1])
endf
"}}}1
" * Open & Close {{{1
@ -576,7 +580,7 @@ fu! s:Update(str)
let s:martcs = &scs && str =~ '\u' ? '\C' : ''
let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winmaxh)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
cal s:Render(lines, pat)
endf

View File

@ -123,7 +123,7 @@ heights of the match window: >
let g:ctrlp_match_window = ''
<
Example: >
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
<
The position: (default: bottom)
top - show the match window at the top of the screen.
@ -137,6 +137,9 @@ The minimum and maximum heights:
min:{n} - show minimum {n} lines (default: 1).
max:{n} - show maximum {n} lines (default: 10).
The maximum number of results:
results:{n} - list maximum {n} results (default: sync with max height).
Note: When a setting isn't set, its default value will be used.
*'g:ctrlp_switch_buffer'*