diff --git a/autoload/airline.vim b/autoload/airline.vim index 5a2dc85..8be602c 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -100,24 +100,8 @@ function! airline#get_statusline(winnr, active) return info.statusline endfunction -function! airline#exec_funcrefs(list, break_early) - " for 7.2; we cannot iterate 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}() - endif - endfor - return 0 -endfunction - function! airline#update_statusline() - if airline#exec_funcrefs(g:airline_exclude_funcrefs, 1) + if airline#util#exec_funcrefs(g:airline_exclude_funcrefs, 1) call setwinvar(winnr(), '&statusline', '') return endif @@ -134,7 +118,7 @@ function! airline#update_statusline() for section in s:sections unlet! w:airline_section_{section} endfor - call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0) + call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0) call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1)) endfunction diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3141dab..6846eb5 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -94,7 +94,7 @@ endfunction function! s:sync_active_winnr() if exists('#airline') && winnr() != s:active_winnr - if airline#exec_funcrefs(s:ext._cursormove_funcrefs, 1) + if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs, 1) return endif call airline#update_statusline() @@ -158,6 +158,6 @@ function! airline#extensions#load() call airline#extensions#iminsert#init() endif - call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0) + call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0) endfunction diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim new file mode 100644 index 0000000..b40b34a --- /dev/null +++ b/autoload/airline/util.vim @@ -0,0 +1,18 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#util#exec_funcrefs(list, break_early) + " for 7.2; we cannot iterate 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}() + endif + endfor + return 0 +endfunction