From e0791cc1a00e1ab225355b6a0704882c8879ea50 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 12 Mar 2018 20:31:50 +0000 Subject: [PATCH] Use the partially built tabline to calculate space left for tabs --- autoload/airline/extensions/tabline/tabs.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index 3db6d92..61deaee 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -123,7 +123,15 @@ function! airline#extensions#tabline#tabs#get() call airline#extensions#tabline#add_label(b, 'buffers') endif - for i in s:get_visible_tabs(&columns) + 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') + + for i in s:get_visible_tabs(&columns - strlen(b_tabline)) if i < 0 call b.insert_raw('%#airline_tab#...', tabs_position) let tabs_position += 1