From f93894f6ac28e6bb1c633e2d18952ae290c8820a Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 14 Mar 2018 13:55:30 +0000 Subject: [PATCH] Move tab title generation into its own function --- autoload/airline/extensions/tabline/tabs.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index d713719..60524a9 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -98,6 +98,16 @@ function! s:evaluate_tabline(tabline) return tabline endfunction +function! s:get_title(tab_nr_type, i) + let val = '%(' + + if get(g:, 'airline#extensions#tabline#show_tab_nr', 1) + let val .= airline#extensions#tabline#tabs#tabnr_formatter(a:tab_nr_type, a:i) + endif + + return val.'%'.a:i.'T %{airline#extensions#tabline#title('.a:i.')} %)' +endfunction + function! airline#extensions#tabline#tabs#get() let curbuf = bufnr('%') let curtab = tabpagenr() @@ -141,13 +151,7 @@ function! airline#extensions#tabline#tabs#get() let tab_titles = [] for i in range(1, tabpagenr('$')) - let val = '%(' - - if get(g:, 'airline#extensions#tabline#show_tab_nr', 1) - let val .= airline#extensions#tabline#tabs#tabnr_formatter(tab_nr_type, i) - endif - - call add(tab_titles, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)') + call add(tab_titles, s:get_title(tab_nr_type, i)) endfor for i in s:get_visible_tabs(&columns - strlen(b_tabline), tab_titles)