From b5e8ea275ee4c9111906c7863195c4e48c356660 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sun, 22 Sep 2013 17:15:02 -0400 Subject: [PATCH] do not render accents in inactive splits. resolves #270. --- autoload/airline/builder.vim | 23 ++++++++++++++--------- t/builder.vim | 6 ++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index c35c6bcd..b1a1e27a 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -23,15 +23,20 @@ function! s:prototype.add_section(group, contents) let self._line .= '%#'.a:group.'#' endif - let contents = [] - let content_parts = split(a:contents, '__accent') - for cpart in content_parts - let accent = matchstr(cpart, '_\zs[^#]*\ze') - call airline#highlighter#add_accent(a:group, accent) - call add(contents, cpart) - endfor - let line = join(contents, a:group) - let line = substitute(line, '__restore__', a:group, 'g') + if self._context.active + let contents = [] + let content_parts = split(a:contents, '__accent') + for cpart in content_parts + let accent = matchstr(cpart, '_\zs[^#]*\ze') + call airline#highlighter#add_accent(a:group, accent) + call add(contents, cpart) + endfor + let line = join(contents, a:group) + let line = substitute(line, '__restore__', a:group, 'g') + else + let line = substitute(a:contents, '%#__accent[^#]*#', '', 'g') + let line = substitute(line, '%#__restore__#', '', 'g') + endif let self._line .= line let self._curgroup = a:group diff --git a/t/builder.vim b/t/builder.vim index 43076afe..3d1afcda 100644 --- a/t/builder.vim +++ b/t/builder.vim @@ -70,5 +70,11 @@ describe 'inactive builder' let stl = s:builder.build() Expect stl =~ '%#Normal_inactive#hello%#Normal_to_NonText_inactive#>%#NonText_inactive#world' end + + it 'should not render accents' + call s:builder.add_section('Normal', '%#__accent_foo#hello%#foo#foo%#__accent_bar#world') + let stl = s:builder.build() + Expect stl == '%#Normal_inactive#hello%#foo_inactive#fooworld' + end end