From bc8fdfe946e1a3dd8b711d5bab1a3de13a5449d9 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sun, 21 Jun 2020 22:24:36 +0200 Subject: [PATCH] terminal: correctly shorten terminal tabline If there is a single terminal window in the current tabpage, the whole long command will be displayed in the tabline, even when it should be shortened by default. By default the title will not be shown if there are several windows in the current tabpage, but if there is only one single terminal window, it will still be shown (and might be a bit long). But I guess, it is better to just show a possible too long terminal window name, than not show anything). fixes #2126 --- autoload/airline/extensions/tabline.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/airline/extensions/tabline.vim b/autoload/airline/extensions/tabline.vim index ea76267b..b862475e 100644 --- a/autoload/airline/extensions/tabline.vim +++ b/autoload/airline/extensions/tabline.vim @@ -190,9 +190,11 @@ function! airline#extensions#tabline#title(n) let buflist = tabpagebuflist(a:n) let winnr = tabpagewinnr(a:n) let all_buffers = airline#extensions#tabline#buflist#list() - return airline#extensions#tabline#get_buffer_name( - \ buflist[winnr - 1], - \ filter(buflist, 'index(all_buffers, v:val) != -1')) + let curbuf = filter(buflist, 'index(all_buffers, v:val) != -1') + if len(curbuf) == 0 + call add(curbuf, tabpagebuflist()[0]) + endif + return airline#extensions#tabline#get_buffer_name(curbuf[0], curbuf) endif return title