Use get() to access members of getwininfo() function

And add default value, in case the 'loclist' and 'quickfix' entry is not
available (can happen on versions without +quickfix feature).

Fixes #1379
This commit is contained in:
Christian Brabandt 2017-01-21 22:02:40 +01:00
parent 9a95964256
commit b56a064377
1 changed files with 2 additions and 2 deletions

View File

@ -29,9 +29,9 @@ endfunction
function! s:get_text()
if exists("*win_getid") && exists("*getwininfo")
let dict = getwininfo(win_getid())
if len(dict) > 0 && dict[0].quickfix && !dict[0].loclist
if len(dict) > 0 && get(dict[0], 'quickfix', 0) && !get(dict[0], 'loclist', 0)
return g:airline#extensions#quickfix#quickfix_text
elseif len(dict) > 0 && dict[0].quickfix && dict[0].loclist
elseif len(dict) > 0 && get(dict[0], 'quickfix', 0) && get(dict[0], 'loclist', 0)
return g:airline#extensions#quickfix#location_text
endif
endif