From fbdf39c403bd7e4d888f37d4c846ba4b8364b4d7 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Mon, 2 Sep 2013 03:03:36 +0000 Subject: [PATCH] better handling of blank buffers. --- autoload/airline/extensions/tabline.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/autoload/airline/extensions/tabline.vim b/autoload/airline/extensions/tabline.vim index dc8259f..87931a8 100644 --- a/autoload/airline/extensions/tabline.vim +++ b/autoload/airline/extensions/tabline.vim @@ -29,9 +29,9 @@ function! airline#extensions#tabline#get() for nr in range(1, bufnr('$')) if buflisted(nr) && bufexists(nr) if cur == nr - call b.add_section('airline_tablinesel', '%( %{fnamemodify(bufname('.nr.'),"'.s:fmod.'")} %)') + call b.add_section('airline_tablinesel', '%( %{airline#extensions#tabline#get_buffer_name('.nr.')} %)') else - call b.add_section('airline_tabline', '%( %{fnamemodify(bufname('.nr.'),"'.s:fmod.'")} %)') + call b.add_section('airline_tabline', '%( %{airline#extensions#tabline#get_buffer_name('.nr.')} %)') endif endif endfor @@ -59,6 +59,14 @@ endfunction function! airline#extensions#tabline#title(n) let buflist = tabpagebuflist(a:n) let winnr = tabpagewinnr(a:n) - return fnamemodify(bufname(buflist[winnr - 1]), s:fmod) + return airline#extensions#tabline#get_buffer_name(buflist[winnr - 1]) +endfunction + +function! airline#extensions#tabline#get_buffer_name(nr) + let name = bufname(a:nr) + if empty(name) + return '[No Name]' + endif + return fnamemodify(name, s:fmod) endfunction