break early implicit if return code is not 0.

This commit is contained in:
Bailey Ling 2013-08-22 03:12:07 +00:00
parent db3a4b1df6
commit e83e12447e
3 changed files with 13 additions and 18 deletions

View File

@ -73,7 +73,7 @@ function! airline#get_statusline(winnr, active)
endfunction
function! airline#update_statusline()
if airline#util#exec_funcrefs(g:airline_exclude_funcrefs, 1)
if airline#util#exec_funcrefs(g:airline_exclude_funcrefs)
call setwinvar(winnr(), '&statusline', '')
return
endif
@ -90,7 +90,7 @@ function! airline#update_statusline()
for section in s:sections
unlet! w:airline_section_{section}
endfor
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0)
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs)
call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1))
endfunction

View File

@ -95,7 +95,7 @@ endfunction
function! s:sync_active_winnr()
if exists('#airline') && winnr() != s:active_winnr
if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs, 1)
if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs)
return
endif
call airline#update_statusline()
@ -194,6 +194,6 @@ function! airline#extensions#load()
endif
endfor
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0)
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs)
endfunction

View File

@ -13,29 +13,24 @@ else
endif
if v:version >= 704
function! airline#util#exec_funcrefs(list, break_early, ...)
function! airline#util#exec_funcrefs(list, ...)
for Fn in a:list
if a:break_early
if Fn()
return 1
endif
else
call Fn()
let code = Fn(a:000)
if code != 0
return code
endif
endfor
return 0
endfunction
else
function! airline#util#exec_funcrefs(list, break_early, ...)
function! airline#util#exec_funcrefs(list, ...)
" for 7.2; we cannot iterate the list, hence why we use range()
" for 7.3-[97, 328]; we cannot reuse the variable, hence the {}
for i in range(0, len(a:list) - 1)
let Fn{i} = a:list[i]
if a:break_early
if Fn{i}()
return 1
endif
else
call Fn{i}()
let code = Fn{i}(a:000)
if code != 0
return code
endif
endfor
return 0