From 2711c73a47eeb848ddec42c5f8f62a6cb85f941e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 12 Mar 2018 18:12:08 +0000 Subject: [PATCH] Pass the available space for tabs as an argument to |get_visible_tabs| --- autoload/airline/extensions/tabline/tabs.vim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index e715b13..596013a 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -25,7 +25,7 @@ function! airline#extensions#tabline#tabs#invalidate() let s:current_bufnr = -1 endfunction -function! s:get_visible_tabs() +function! s:get_visible_tabs(width) let tablist = range(1, tabpagenr('$')) let curbuf = bufnr('%') @@ -48,13 +48,12 @@ function! s:get_visible_tabs() " only show current and surrounding tabs if there are too many tabs let position = index(tablist, curbuf) - let vimwidth = &columns - if total_width > vimwidth && position > -1 + if total_width > a:width && position > -1 let tab_count = len(tablist) " determine how many tabs to show based on the longest tab width, " use one on the right side and put the rest on the left - let tab_max = vimwidth / max_width + let tab_max = a:width / max_width let tab_right = 1 let tab_left = max([0, tab_max - tab_right]) @@ -103,7 +102,7 @@ function! airline#extensions#tabline#tabs#get() let b = airline#extensions#tabline#new_builder() call airline#extensions#tabline#add_label(b, 'tabs') - for i in s:get_visible_tabs() + for i in s:get_visible_tabs(&columns) if i < 0 call b.add_raw('%#airline_tab#...') continue