diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 25f510b..4048d72 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -19,7 +19,11 @@ function! s:prototype.add_section(group, contents) endif endif - let self._line .= '%#'.a:group.'#'.a:contents + if self._curgroup != a:group + let self._line .= '%#'.a:group.'#' + endif + + let self._line .= a:contents let self._curgroup = a:group endfunction diff --git a/t/builder.vim b/t/builder.vim index 0c12d32..2ba9981 100644 --- a/t/builder.vim +++ b/t/builder.vim @@ -30,6 +30,13 @@ describe 'active builder' let stl = s:builder.build() Expect stl =~ '%#Normal#hello%#Normal_to_NonText#<%#NonText#world' end + + it 'should not repeat the same highlight group' + call s:builder.add_section('Normal', 'hello') + call s:builder.add_section('Normal', 'hello') + let stl = s:builder.build() + Expect stl == '%#Normal#hello>hello' + end end describe 'inactive builder'