account for possibilty of branch extension unavailable. resolves #419.

This commit is contained in:
Bailey Ling 2014-01-20 12:39:33 -05:00
parent baed8ac063
commit fae68dbcb7
2 changed files with 9 additions and 6 deletions

View File

@ -47,7 +47,6 @@ function! airline#extensions#branch#get_head()
let empty_message = get(g:, 'airline#extensions#branch#empty_message', let empty_message = get(g:, 'airline#extensions#branch#empty_message',
\ get(g:, 'airline_branch_empty_message', '')) \ get(g:, 'airline_branch_empty_message', ''))
let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)
return empty(head) return empty(head)
\ ? empty_message \ ? empty_message
\ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head) \ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head)

View File

@ -7,11 +7,15 @@ endif
function! airline#extensions#netrw#apply(...) function! airline#extensions#netrw#apply(...)
if &ft == 'netrw' if &ft == 'netrw'
call a:1.add_section('airline_a', ' netrw ') let spc = g:airline_symbols.space
call a:1.add_section('airline_b', ' %{airline#extensions#branch#get_head()} ')
call a:1.add_section('airline_c', ' %f ') call a:1.add_section('airline_a', spc.'netrw'.spc)
if exists('*airline#extensions#branch#get_head')
call a:1.add_section('airline_b', spc.'%{airline#extensions#branch#get_head()}'.spc)
endif
call a:1.add_section('airline_c', spc.'%f'.spc)
call a:1.split() call a:1.split()
call a:1.add_section('airline_y', ' %{airline#extensions#netrw#sortstring()} ') call a:1.add_section('airline_y', spc.'%{airline#extensions#netrw#sortstring()}'.spc)
return 1 return 1
endif endif
endfunction endfunction
@ -24,5 +28,5 @@ endfunction
function! airline#extensions#netrw#sortstring() function! airline#extensions#netrw#sortstring()
let order = (g:netrw_sort_direction =~ 'n') ? '+' : '-' let order = (g:netrw_sort_direction =~ 'n') ? '+' : '-'
return g:netrw_sort_by . ' [' . order . ']' return g:netrw_sort_by . (g:airline_symbols.space) . '[' . order . ']'
endfunction endfunction