diff --git a/autoload/airline/extensions/tabline/builder.vim b/autoload/airline/extensions/tabline/builder.vim index 2ce97c77..d0a0a319 100644 --- a/autoload/airline/extensions/tabline/builder.vim +++ b/autoload/airline/extensions/tabline/builder.vim @@ -16,7 +16,7 @@ endfunction function! s:prototype.try_insert_title(index, group, pos, sep_size, force) dict let title = self.get_title(a:index) - let self._remaining_space -= s:strchars(s:evaluate_tabline(title)) + a:sep_size + let self._remaining_space -= airline#util#strchars(s:evaluate_tabline(title)) + a:sep_size if a:force || self._remaining_space >= 0 let pos = a:pos if has_key(self, "get_pretitle") @@ -37,7 +37,7 @@ function! s:prototype.try_insert_title(index, group, pos, sep_size, force) dict return 1 else - let self._remaining_space += s:strchars(s:evaluate_tabline(title)) + a:sep_size + let self._remaining_space += airline#util#strchars(s:evaluate_tabline(title)) + a:sep_size endif return 0 endfunction @@ -58,15 +58,15 @@ endfunction function! s:prototype.build() dict if has_key(self, '_left_position') - let self._remaining_space = &columns - s:strchars(s:evaluate_tabline(self._build())) + let self._remaining_space = &columns - airline#util#strchars(s:evaluate_tabline(self._build())) let center_active = get(g:, 'airline#extensions#tabline#center_active', 0) - let sep_size = s:strchars(s:evaluate_tabline(self._context.left_sep)) - let alt_sep_size = s:strchars(s:evaluate_tabline(self._context.left_alt_sep)) + let sep_size = airline#util#strchars(s:evaluate_tabline(self._context.left_sep)) + let alt_sep_size = airline#util#strchars(s:evaluate_tabline(self._context.left_alt_sep)) let overflow_marker = get(g:, 'airline#extensions#tabline#overflow_marker', g:airline_symbols.ellipsis) - let overflow_marker_size = s:strchars(s:evaluate_tabline(overflow_marker)) + let overflow_marker_size = airline#util#strchars(s:evaluate_tabline(overflow_marker)) " Allow space for the markers before we begin filling in titles. let self._remaining_space -= 2 * overflow_marker_size @@ -153,16 +153,6 @@ function! s:evaluate_tabline(tabline) return tabline endfunction -" Compatibility wrapper for strchars, in case this vim version does not -" have it natively -function! s:strchars(str) - if exists('*strchars') - return strchars(a:str) - else - return strlen(substitute(a:str, '.', 'a', 'g')) - endif -endfunction - function! airline#extensions#tabline#builder#new(context) let builder = airline#builder#new(a:context) let builder._build = builder.build diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index e0bec92d..23c44c43 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -86,3 +86,13 @@ else return 0 endfunction endif + +" Compatibility wrapper for strchars, in case this vim version does not +" have it natively +function! airline#util#strchars(str) + if exists('*strchars') + return strchars(a:str) + else + return strlen(substitute(a:str, '.', 'a', 'g')) + endif +endfunction