limit the number of buffers displayed. fixes #221.

This commit is contained in:
Bailey Ling 2013-09-05 17:07:31 +00:00
parent 2cfe26f72f
commit fc6cf26ac6
1 changed files with 13 additions and 0 deletions

View File

@ -20,6 +20,9 @@ let s:builder_context = {
let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0) let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0)
let s:buf_len = 0 let s:buf_len = 0
" TODO: temporary
let s:buf_max = get(g:, 'airline#extensions#tabline#buffer_max', 6)
function! airline#extensions#tabline#init(ext) function! airline#extensions#tabline#init(ext)
if has('gui_running') if has('gui_running')
set guioptions-=e set guioptions-=e
@ -111,6 +114,16 @@ function! s:get_buffer_list()
call add(buffers, nr) call add(buffers, nr)
endif endif
endfor endfor
" TODO: temporary fix; force the active buffer to be first when there are many buffers open
if len(buffers) > s:buf_max
while buffers[0] != cur
let first = remove(buffers, 0)
call add(buffers, first)
endwhile
let buffers = buffers[:s:buf_max]
endif
return buffers return buffers
endfunction endfunction