Add a get_tabs function to abstract over tabs

This commit is contained in:
mrmr1993 2018-03-10 01:04:18 +00:00
parent 958f78335e
commit f60cf736db

View File

@ -25,6 +25,20 @@ function! airline#extensions#tabline#tabs#invalidate()
let s:current_bufnr = -1 let s:current_bufnr = -1
endfunction endfunction
function! s:get_tabs()
let tablist = range(1, tabpagenr('$'))
let curbuf = bufnr('%')
if get(g:, 'airline#extensions#tabline#current_first', 0)
" always have current tabpage first
if index(tablist, curtab) > -1
call remove(tablist, index(tablist, curtab))
endif
let tablist = [curtab] + tablist
endif
return tablist
endfunction
function! airline#extensions#tabline#tabs#get() function! airline#extensions#tabline#tabs#get()
let curbuf = bufnr('%') let curbuf = bufnr('%')
let curtab = tabpagenr() let curtab = tabpagenr()
@ -43,15 +57,7 @@ function! airline#extensions#tabline#tabs#get()
let b = airline#extensions#tabline#new_builder() let b = airline#extensions#tabline#new_builder()
call airline#extensions#tabline#add_label(b, 'tabs') call airline#extensions#tabline#add_label(b, 'tabs')
" always have current tabpage first for i in s:get_tabs()
let tablist = range(1, tabpagenr('$'))
if get(g:, 'airline#extensions#tabline#current_first', 0)
if index(tablist, curtab) > -1
call remove(tablist, index(tablist, curtab))
endif
let tablist = [curtab] + tablist
endif
for i in tablist
if i == curtab if i == curtab
let group = 'airline_tabsel' let group = 'airline_tabsel'
if g:airline_detect_modified if g:airline_detect_modified