From 3305410982d1d6ccb93195059d324ff62a0adbef Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 12 Mar 2018 20:37:37 +0000 Subject: [PATCH] Move tabline evaluation into its own function --- autoload/airline/extensions/tabline/tabs.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index 61deaee..1cd1e5b 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -84,6 +84,17 @@ function! s:get_visible_tabs(width) return tablist endfunction +function! s:evaluate_tabline(tabline) + let tabline = a:tabline + let tabline = substitute(tabline, '%{\([^}]\+\)}', '\=eval(submatch(1))', 'g') + let tabline = substitute(tabline, '%#[^#]\+#', '', 'g') + let tabline = substitute(tabline, '%(\([^)]\+\))', '\1', 'g') + let tabline = substitute(tabline, '%\d\+[TX]', '', 'g') + let tabline = substitute(tabline, '%=', '', 'g') + let tabline = substitute(tabline, '%\d*\*', '', 'g') + return tabline +endfunction + function! airline#extensions#tabline#tabs#get() let curbuf = bufnr('%') let curtab = tabpagenr() @@ -123,13 +134,7 @@ function! airline#extensions#tabline#tabs#get() call airline#extensions#tabline#add_label(b, 'buffers') endif - let b_tabline = b.build() - let b_tabline = substitute(b_tabline, '%{\([^}]\+\)}', '\=eval(submatch(1))', 'g') - let b_tabline = substitute(b_tabline, '%#[^#]\+#', '', 'g') - let b_tabline = substitute(b_tabline, '%(\([^)]\+\))', '\1', 'g') - let b_tabline = substitute(b_tabline, '%\d\+[TX]', '', 'g') - let b_tabline = substitute(b_tabline, '%=', '', 'g') - let b_tabline = substitute(b_tabline, '%\d*\*', '', 'g') + let b_tabline = s:evaluate_tabline(b.build()) for i in s:get_visible_tabs(&columns - strlen(b_tabline)) if i < 0