From f60cf736db5ef551ad9adc5df3e3f50dc3e956cb Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 10 Mar 2018 01:04:18 +0000 Subject: [PATCH] Add a get_tabs function to abstract over tabs --- autoload/airline/extensions/tabline/tabs.vim | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index 54019b5..d7b662f 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -25,6 +25,20 @@ function! airline#extensions#tabline#tabs#invalidate() let s:current_bufnr = -1 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() let curbuf = bufnr('%') let curtab = tabpagenr() @@ -43,15 +57,7 @@ function! airline#extensions#tabline#tabs#get() let b = airline#extensions#tabline#new_builder() call airline#extensions#tabline#add_label(b, 'tabs') - " always have current tabpage first - 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 + for i in s:get_tabs() if i == curtab let group = 'airline_tabsel' if g:airline_detect_modified