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
This commit is contained in:
Christian Brabandt 2020-06-21 22:24:36 +02:00
parent 5ce3e63658
commit bc8fdfe946
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -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