fix seperator drawing when tabs are shown. fixes #653.
This commit is contained in:
parent
15666d71e3
commit
6b4f03efbc
@ -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 = []
|
||||
|
@ -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()
|
||||
|
@ -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 <sid>build_sections(a:builder, a:context, s:layout[0])
|
||||
call s:build_sections(a:builder, a:context, s:layout[0])
|
||||
else
|
||||
let text = <sid>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 <sid>build_sections(a:builder, a:context, s:layout[1])
|
||||
call s:build_sections(a:builder, a:context, s:layout[1])
|
||||
endif
|
||||
|
||||
return 1
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user