From e83e12447e5fcaa8314aee05a716c30e0f30e228 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Thu, 22 Aug 2013 03:12:07 +0000 Subject: [PATCH] break early implicit if return code is not 0. --- autoload/airline.vim | 4 ++-- autoload/airline/extensions.vim | 4 ++-- autoload/airline/util.vim | 23 +++++++++-------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 0980f214..b0480de1 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -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 diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3ca6cbb0..52f8de3f 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -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 diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index b63898ec..10fb6ac7 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -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