From 896c14bded5b2e5852c5509b1ab84f526b9512a9 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 17 Mar 2018 19:59:47 +0000 Subject: [PATCH] Reset _remaining_space if a title can't be inserted This gives us a chance to add the title on the other side if it will fit, so that we fill more space in the tabline. --- autoload/airline/extensions/tabline/builder.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/airline/extensions/tabline/builder.vim b/autoload/airline/extensions/tabline/builder.vim index 86dc27b..940ccb0 100644 --- a/autoload/airline/extensions/tabline/builder.vim +++ b/autoload/airline/extensions/tabline/builder.vim @@ -36,6 +36,8 @@ function! s:prototype.try_insert_tab(tab, pos, sep_size, force) dict endif return 1 + else + let self._remaining_space += s:strchars(s:evaluate_tabline(tab_title)) + a:sep_size endif return 0 endfunction @@ -76,14 +78,12 @@ function! s:prototype.build() dict while self._remaining_space > 0 let done = 0 if self._left_tab >= self._first_tab - let self._left_tab -= - \ self.try_insert_tab(self._left_tab, self._left_position, left_alt_sep_size, 0) - let done = 1 + let done = self.try_insert_tab(self._left_tab, self._left_position, left_alt_sep_size, 0) + let self._left_tab -= done endif if self._right_tab <= self._last_tab && (center_active || !done) - let self._right_tab += - \ self.try_insert_tab(self._right_tab, self._right_position, left_alt_sep_size, 0) - let done = 1 + let done = self.try_insert_tab(self._right_tab, self._right_position, left_alt_sep_size, 0) + let self._right_tab += done endif if !done break