tabline: fix s:current_buffer_list invalidation

Use `s:current_buffer_list` always in `s:get_buffer_list()`, and
invalidate it via BufAdd and BufUnload.

Fixes regression from ce58af7191 (commitcomment-9647487).
This commit is contained in:
Daniel Hahler 2015-02-09 17:44:13 +01:00
parent 925147baef
commit 3c1295bb71

View File

@ -59,19 +59,22 @@ function! s:toggle_on()
let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ] let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ]
set tabline=%!airline#extensions#tabline#get() set tabline=%!airline#extensions#tabline#get()
if s:buf_min_count <= 0 && s:tab_min_count <= 1 augroup airline_tabline
set showtabline=2 autocmd!
else " Invalidate cache.
augroup airline_tabline autocmd BufAdd,BufUnload * unlet! s:current_buffer_list
autocmd!
if s:buf_min_count <= 0 && s:tab_min_count <= 1
set showtabline=2
else
if s:show_buffers == 1 if s:show_buffers == 1
autocmd BufEnter * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list())) autocmd BufEnter * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list()))
autocmd BufUnload * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list()) - 1) autocmd BufUnload * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list()) - 1)
else else
autocmd TabEnter * call <sid>show_tabline(s:tab_min_count, tabpagenr('$')) autocmd TabEnter * call <sid>show_tabline(s:tab_min_count, tabpagenr('$'))
endif endif
augroup END endif
endif augroup END
endfunction endfunction
function! airline#extensions#tabline#load_theme(palette) function! airline#extensions#tabline#load_theme(palette)
@ -130,13 +133,14 @@ function! airline#extensions#tabline#title(n)
endfunction endfunction
function! airline#extensions#tabline#get_buffer_name(nr) function! airline#extensions#tabline#get_buffer_name(nr)
let buffer_list = exists('s:current_buffer_list') return airline#extensions#tabline#{s:formatter}#format(a:nr, s:get_buffer_list())
\ ? s:current_buffer_list
\ : s:get_buffer_list()
return airline#extensions#tabline#{s:formatter}#format(a:nr, buffer_list)
endfunction endfunction
function! s:get_buffer_list() function! s:get_buffer_list()
if exists('s:current_buffer_list')
return s:current_buffer_list
endif
let buffers = [] let buffers = []
let cur = bufnr('%') let cur = bufnr('%')
for nr in range(1, bufnr('$')) for nr in range(1, bufnr('$'))