From a7bff3b30bb89652eb9bde51280f29221cecf34c Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Thu, 15 Mar 2018 18:20:37 +0000 Subject: [PATCH] Pass number of tabs as an argument to insert_tabs --- autoload/airline/extensions/tabline/builder.vim | 10 +++++----- autoload/airline/extensions/tabline/tabs.vim | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/airline/extensions/tabline/builder.vim b/autoload/airline/extensions/tabline/builder.vim index 16ba3a3..8b1dfa4 100644 --- a/autoload/airline/extensions/tabline/builder.vim +++ b/autoload/airline/extensions/tabline/builder.vim @@ -5,7 +5,8 @@ scriptencoding utf-8 let s:prototype = {} -function! s:prototype.insert_tabs(curtab) dict +function! s:prototype.insert_tabs(curtab, numtabs) dict + let self._num_tabs = a:numtabs let self._left_tab = a:curtab let self._right_tab = a:curtab + 1 let self._left_position = self.get_position() @@ -25,7 +26,6 @@ endfunction function! s:prototype.build() dict if has_key(self, '_left_position') - let num_tabs = tabpagenr('$') let self._remaining_space = &columns - s:strchars(s:evaluate_tabline(self._build())) let left_sep_size = s:strchars(s:evaluate_tabline(self._context.left_sep)) @@ -50,7 +50,7 @@ function! s:prototype.build() dict endif " Add the tab to the right - if self._right_tab <= num_tabs + if self._right_tab <= self._num_tabs let self._right_tab += \ self.try_insert_tab(self._right_tab, self._right_position, left_alt_sep_size, 1) endif @@ -59,7 +59,7 @@ function! s:prototype.build() dict if self._left_tab > 0 let self._left_tab -= \ self.try_insert_tab(self._left_tab, self._left_position, left_alt_sep_size, 0) - elseif self._right_tab <= num_tabs + elseif self._right_tab <= self._num_tabs let self._right_tab += \ self.try_insert_tab(self._right_tab, self._right_position, left_alt_sep_size, 0) else @@ -75,7 +75,7 @@ function! s:prototype.build() dict let self._right_position += 1 endif - if self._right_tab <= num_tabs + if self._right_tab <= self._num_tabs call self.insert_raw('%#airline_tab#'.skipped_tabs_marker, self._right_position) endif endif diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index d238473..eea7301 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -71,7 +71,7 @@ function! airline#extensions#tabline#tabs#get() return val.'%'.a:i.'T %{airline#extensions#tabline#title('.a:i.')} %)' endfunction - call b.insert_tabs(curtab) + call b.insert_tabs(curtab, tabpagenr('$')) call b.add_section('airline_tabfill', '') call b.split()