diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 52c3f5a..5f4e080 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -19,35 +19,47 @@ function! s:prototype.add_raw(text) call add(self._sections, ['', a:text]) endfunction +function! s:get_prev_group(sections, i) + let x = a:i - 1 + while x >= 0 + let group = a:sections[x][0] + if group != '' && group != '|' + return group + endif + let x = x - 1 + endwhile + return '' +endfunction + function! s:prototype.build() let side = 1 - let prev_group = '' let line = '' let i = 0 let length = len(self._sections) + let split = 0 while i < length let section = self._sections[i] let group = section[0] let contents = section[1] + let prev_group = s:get_prev_group(self._sections, i) if group == '' let line .= contents elseif group == '|' let side = 0 let line .= contents - let prev_group = '' + let split = 1 else - if i == 0 + if prev_group == '' let line .= '%#'.group.'#' - endif - - if prev_group != '' && group != '' + elseif split + let line .= s:get_transitioned_seperator(self, prev_group, group, side) + let split = 0 + else let line .= s:get_seperator(self, prev_group, group, side) endif - let line .= s:get_accented_line(self, group, contents) - let prev_group = group endif let i = i + 1 @@ -72,19 +84,23 @@ function! s:should_change_group(group1, group2) endif endfunction -function! s:get_seperator(self, prev_group, group, side) +function! s:get_transitioned_seperator(self, prev_group, group, side) let line = '' - if s:should_change_group(a:prev_group, a:group) - call airline#highlighter#add_separator(a:prev_group, a:group, a:side) - let line .= '%#'.a:prev_group.'_to_'.a:group.'#' - let line .= a:side ? a:self._context.left_sep : a:self._context.right_sep - let line .= '%#'.a:group.'#' - else - let line .= a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep - endif + call airline#highlighter#add_separator(a:prev_group, a:group, a:side) + let line .= '%#'.a:prev_group.'_to_'.a:group.'#' + let line .= a:side ? a:self._context.left_sep : a:self._context.right_sep + let line .= '%#'.a:group.'#' return line endfunction +function! s:get_seperator(self, prev_group, group, side) + if s:should_change_group(a:prev_group, a:group) + return s:get_transitioned_seperator(a:self, a:prev_group, a:group, a:side) + else + return a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep + endif +endfunction + function! s:get_accented_line(self, group, contents) if a:self._context.active let contents = [] diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index 11a8922..b195755 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -48,7 +48,7 @@ function! airline#extensions#ctrlp#ctrlp_airline(...) endif call b.add_section_spaced('CtrlPdark', a:7) call b.split() - call b.add_raw('%#CtrlPdark#'.a:1.(g:airline_symbols.space)) + call b.add_section_spaced('CtrlPdark', a:1) call b.add_section_spaced('CtrlPdark', a:2) call b.add_section_spaced('CtrlPlight', '%{getcwd()}') return b.build() diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/extensions/default.vim index 53b000d..faa1fb6 100644 --- a/autoload/airline/extensions/default.vim +++ b/autoload/airline/extensions/default.vim @@ -61,9 +61,9 @@ function! airline#extensions#default#apply(builder, context) let active = a:context.active if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse)) - call build_sections(a:builder, a:context, s:layout[0]) + call s:build_sections(a:builder, a:context, s:layout[0]) else - let text = get_section(winnr, 'c') + let text = s:get_section(winnr, 'c') if empty(text) let text = ' %f%m ' endif @@ -73,7 +73,7 @@ function! airline#extensions#default#apply(builder, context) call a:builder.split(s:get_section(winnr, 'gutter', '', '')) if airline#util#getwinvar(winnr, 'airline_render_right', 1) - call build_sections(a:builder, a:context, s:layout[1]) + call s:build_sections(a:builder, a:context, s:layout[1]) endif return 1 diff --git a/t/builder.vim b/t/builder.vim index d82367e..57feb14 100644 --- a/t/builder.vim +++ b/t/builder.vim @@ -75,6 +75,14 @@ describe 'active builder' Expect stl !~ '%#__restore__#' Expect stl =~ '%#Normal#' end + + it 'should blend colors from the left through the split to the right' + call s:builder.add_section('Normal', 'hello') + call s:builder.split() + call s:builder.add_section('Search', 'world') + let stl = s:builder.build() + Expect stl =~ 'Normal_to_Search' + end end describe 'inactive builder'