From 53b856b0c5f159f65c512621a7539fd0a37d7546 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 24 Aug 2013 03:43:55 +0000 Subject: [PATCH] inactivate existing statusline without building a new one. --- autoload/airline.vim | 14 ++++++++------ autoload/airline/builder.vim | 6 +----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 29a9d01..907093c 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -94,10 +94,12 @@ endfunction function! airline#update_statusline() for nr in filter(range(1, winnr('$')), 'v:val != winnr()') - call setwinvar(nr, 'airline_active', 0) - let context = { 'winnr': nr, 'active': 0 } - let builder = airline#builder#new(context, s:highlighter) - call setwinvar(nr, '&statusline', airline#get_statusline(builder, nr, 0)) + if airline#util#getwinvar(nr, 'airline_active', 0) + call setwinvar(nr, 'airline_active', 0) + let stl = getwinvar(nr, '&statusline') + let line = substitute(stl, '%#.\{-}\ze#', '\0_inactive', 'g') + call setwinvar(nr, '&statusline', line) + endif endfor let w:airline_active = 1 @@ -109,8 +111,8 @@ function! airline#update_statusline() endfor let context = { 'winnr': winnr(), 'active': 1 } - let builder = airline#builder#new(context, s:highlighter) - let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder) + let builder = airline#builder#new(s:highlighter) + let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder, context) if err == 0 call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1)) elseif err == 1 diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 04467a6..87da340 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -24,15 +24,11 @@ function! s:prototype.add_raw(text) endfunction function! s:prototype.build() - if !self._context.active - let self._line = substitute(self._line, '%#.\{-}\ze#', '\0_inactive', 'g') - endif return self._line endfunction -function! airline#builder#new(context, highlighter) +function! airline#builder#new(highlighter) let builder = copy(s:prototype) - let builder._context = a:context let builder._highlighter = a:highlighter let builder._side = 1 let builder._curgroup = ''