Check that default value exists, before accessing it

closes #1146
This commit is contained in:
Christian Brabandt 2016-04-27 20:11:40 +02:00
parent 81b58028f0
commit 057b429b02
1 changed files with 3 additions and 0 deletions

View File

@ -22,6 +22,9 @@ function! s:get_section(winnr, key, ...)
endif
endif
let spc = g:airline_symbols.space
if !exists('g:airline_section_{a:key}')
return ''
endif
let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key})
let [prefix, suffix] = [get(a:000, 0, '%('.spc), get(a:000, 1, spc.'%)')]
return empty(text) ? '' : prefix.text.suffix