account for possibilty of branch extension unavailable. resolves #419.
This commit is contained in:
parent
baed8ac063
commit
fae68dbcb7
|
@ -47,7 +47,6 @@ function! airline#extensions#branch#get_head()
|
|||
let empty_message = get(g:, 'airline#extensions#branch#empty_message',
|
||||
\ get(g:, 'airline_branch_empty_message', ''))
|
||||
let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)
|
||||
|
||||
return empty(head)
|
||||
\ ? empty_message
|
||||
\ : printf('%s%s', empty(symbol) ? '' : symbol.(g:airline_symbols.space), head)
|
||||
|
|
|
@ -7,11 +7,15 @@ endif
|
|||
|
||||
function! airline#extensions#netrw#apply(...)
|
||||
if &ft == 'netrw'
|
||||
call a:1.add_section('airline_a', ' netrw ')
|
||||
call a:1.add_section('airline_b', ' %{airline#extensions#branch#get_head()} ')
|
||||
call a:1.add_section('airline_c', ' %f ')
|
||||
let spc = g:airline_symbols.space
|
||||
|
||||
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.add_section('airline_y', ' %{airline#extensions#netrw#sortstring()} ')
|
||||
call a:1.add_section('airline_y', spc.'%{airline#extensions#netrw#sortstring()}'.spc)
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
@ -24,5 +28,5 @@ endfunction
|
|||
|
||||
function! airline#extensions#netrw#sortstring()
|
||||
let order = (g:netrw_sort_direction =~ 'n') ? '+' : '-'
|
||||
return g:netrw_sort_by . ' [' . order . ']'
|
||||
return g:netrw_sort_by . (g:airline_symbols.space) . '[' . order . ']'
|
||||
endfunction
|
||||
|
|
Loading…
Reference in New Issue