support multiple accents in the same section (#203).
This commit is contained in:
parent
fdbf2c05a5
commit
9d5a1744a1
@ -23,12 +23,17 @@ function! s:prototype.add_section(group, contents)
|
||||
let self._line .= '%#'.a:group.'#'
|
||||
endif
|
||||
|
||||
let accent = matchstr(a:contents, 'airline_accent_\zs[^#]*\ze')
|
||||
let contents = substitute(a:contents, 'airline_accent', a:group, 'g')
|
||||
if contents != a:contents
|
||||
let contents = []
|
||||
let content_parts = split(a:contents, 'airline_accent')
|
||||
for cpart in content_parts
|
||||
let accent = matchstr(cpart, '_\zs[^#]*\ze')
|
||||
call airline#highlighter#add_accent(a:group, accent)
|
||||
endif
|
||||
let self._line .= contents
|
||||
call add(contents, cpart)
|
||||
endfor
|
||||
let line = join(contents, a:group)
|
||||
let line = substitute(line, '__restore__', a:group, 'g')
|
||||
|
||||
let self._line .= line
|
||||
let self._curgroup = a:group
|
||||
endfunction
|
||||
|
||||
|
@ -49,6 +49,9 @@ function! s:create(parts, append)
|
||||
endif
|
||||
|
||||
let val .= partval
|
||||
if exists('part.accent')
|
||||
let val .= '%#__restore__#'
|
||||
endif
|
||||
let _ .= val
|
||||
endfor
|
||||
return _
|
||||
|
@ -44,6 +44,19 @@ describe 'active builder'
|
||||
let stl = s:builder.build()
|
||||
Expect stl == '%#Normal#%#Normal_foo#hello'
|
||||
end
|
||||
|
||||
it 'should replace two accent groups with correct groups'
|
||||
call s:builder.add_section('Normal', '%#airline_accent_foo#hello%#airline_accent_bar#world')
|
||||
let stl = s:builder.build()
|
||||
Expect stl =~ '%#Normal_foo#hello%#Normal_bar#world'
|
||||
end
|
||||
|
||||
it 'should special restore group should go back to previous group'
|
||||
call s:builder.add_section('Normal', '%#__restore__#')
|
||||
let stl = s:builder.build()
|
||||
Expect stl !~ '%#__restore__#'
|
||||
Expect stl =~ '%#Normal#'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'inactive builder'
|
||||
|
@ -28,7 +28,7 @@ describe 'init'
|
||||
end
|
||||
|
||||
it 'section c should be file'
|
||||
Expect g:airline_section_c == '%<%f%m %#airline_accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}'
|
||||
Expect g:airline_section_c == '%<%f%m %#airline_accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
|
||||
end
|
||||
|
||||
it 'section x should be filetype'
|
||||
|
Loading…
Reference in New Issue
Block a user