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 endfunction
function! airline#update_statusline() 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', '') call setwinvar(winnr(), '&statusline', '')
return return
endif endif
@ -90,7 +90,7 @@ function! airline#update_statusline()
for section in s:sections for section in s:sections
unlet! w:airline_section_{section} unlet! w:airline_section_{section}
endfor 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)) call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1))
endfunction endfunction

View File

@ -95,7 +95,7 @@ endfunction
function! s:sync_active_winnr() function! s:sync_active_winnr()
if exists('#airline') && winnr() != s: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 return
endif endif
call airline#update_statusline() call airline#update_statusline()
@ -194,6 +194,6 @@ function! airline#extensions#load()
endif endif
endfor endfor
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0) call airline#util#exec_funcrefs(g:airline_statusline_funcrefs)
endfunction endfunction

View File

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