mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-21 04:54:45 +02:00
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])
|
call add(self._sections, ['', a:text])
|
||||||
endfunction
|
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()
|
function! s:prototype.build()
|
||||||
let side = 1
|
let side = 1
|
||||||
let prev_group = ''
|
|
||||||
let line = ''
|
let line = ''
|
||||||
let i = 0
|
let i = 0
|
||||||
let length = len(self._sections)
|
let length = len(self._sections)
|
||||||
|
let split = 0
|
||||||
|
|
||||||
while i < length
|
while i < length
|
||||||
let section = self._sections[i]
|
let section = self._sections[i]
|
||||||
let group = section[0]
|
let group = section[0]
|
||||||
let contents = section[1]
|
let contents = section[1]
|
||||||
|
let prev_group = s:get_prev_group(self._sections, i)
|
||||||
|
|
||||||
if group == ''
|
if group == ''
|
||||||
let line .= contents
|
let line .= contents
|
||||||
elseif group == '|'
|
elseif group == '|'
|
||||||
let side = 0
|
let side = 0
|
||||||
let line .= contents
|
let line .= contents
|
||||||
let prev_group = ''
|
let split = 1
|
||||||
else
|
else
|
||||||
if i == 0
|
if prev_group == ''
|
||||||
let line .= '%#'.group.'#'
|
let line .= '%#'.group.'#'
|
||||||
endif
|
elseif split
|
||||||
|
let line .= s:get_transitioned_seperator(self, prev_group, group, side)
|
||||||
if prev_group != '' && group != ''
|
let split = 0
|
||||||
|
else
|
||||||
let line .= s:get_seperator(self, prev_group, group, side)
|
let line .= s:get_seperator(self, prev_group, group, side)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let line .= s:get_accented_line(self, group, contents)
|
let line .= s:get_accented_line(self, group, contents)
|
||||||
let prev_group = group
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let i = i + 1
|
let i = i + 1
|
||||||
@ -72,19 +84,23 @@ function! s:should_change_group(group1, group2)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:get_seperator(self, prev_group, group, side)
|
function! s:get_transitioned_seperator(self, prev_group, group, side)
|
||||||
let line = ''
|
let line = ''
|
||||||
if s:should_change_group(a:prev_group, a:group)
|
|
||||||
call airline#highlighter#add_separator(a:prev_group, a:group, a:side)
|
call airline#highlighter#add_separator(a:prev_group, a:group, a:side)
|
||||||
let line .= '%#'.a:prev_group.'_to_'.a:group.'#'
|
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:side ? a:self._context.left_sep : a:self._context.right_sep
|
||||||
let line .= '%#'.a:group.'#'
|
let line .= '%#'.a:group.'#'
|
||||||
else
|
|
||||||
let line .= a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep
|
|
||||||
endif
|
|
||||||
return line
|
return line
|
||||||
endfunction
|
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)
|
function! s:get_accented_line(self, group, contents)
|
||||||
if a:self._context.active
|
if a:self._context.active
|
||||||
let contents = []
|
let contents = []
|
||||||
|
@ -48,7 +48,7 @@ function! airline#extensions#ctrlp#ctrlp_airline(...)
|
|||||||
endif
|
endif
|
||||||
call b.add_section_spaced('CtrlPdark', a:7)
|
call b.add_section_spaced('CtrlPdark', a:7)
|
||||||
call b.split()
|
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('CtrlPdark', a:2)
|
||||||
call b.add_section_spaced('CtrlPlight', '%{getcwd()}')
|
call b.add_section_spaced('CtrlPlight', '%{getcwd()}')
|
||||||
return b.build()
|
return b.build()
|
||||||
|
@ -61,9 +61,9 @@ function! airline#extensions#default#apply(builder, context)
|
|||||||
let active = a:context.active
|
let active = a:context.active
|
||||||
|
|
||||||
if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse))
|
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
|
else
|
||||||
let text = <sid>get_section(winnr, 'c')
|
let text = s:get_section(winnr, 'c')
|
||||||
if empty(text)
|
if empty(text)
|
||||||
let text = ' %f%m '
|
let text = ' %f%m '
|
||||||
endif
|
endif
|
||||||
@ -73,7 +73,7 @@ function! airline#extensions#default#apply(builder, context)
|
|||||||
call a:builder.split(s:get_section(winnr, 'gutter', '', ''))
|
call a:builder.split(s:get_section(winnr, 'gutter', '', ''))
|
||||||
|
|
||||||
if airline#util#getwinvar(winnr, 'airline_render_right', 1)
|
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
|
endif
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
@ -75,6 +75,14 @@ describe 'active builder'
|
|||||||
Expect stl !~ '%#__restore__#'
|
Expect stl !~ '%#__restore__#'
|
||||||
Expect stl =~ '%#Normal#'
|
Expect stl =~ '%#Normal#'
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'inactive builder'
|
describe 'inactive builder'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user