mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-27 07:54:44 +02:00
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.'#'
|
let self._line .= '%#'.a:group.'#'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let accent = matchstr(a:contents, 'airline_accent_\zs[^#]*\ze')
|
let contents = []
|
||||||
let contents = substitute(a:contents, 'airline_accent', a:group, 'g')
|
let content_parts = split(a:contents, 'airline_accent')
|
||||||
if contents != a:contents
|
for cpart in content_parts
|
||||||
|
let accent = matchstr(cpart, '_\zs[^#]*\ze')
|
||||||
call airline#highlighter#add_accent(a:group, accent)
|
call airline#highlighter#add_accent(a:group, accent)
|
||||||
endif
|
call add(contents, cpart)
|
||||||
let self._line .= contents
|
endfor
|
||||||
|
let line = join(contents, a:group)
|
||||||
|
let line = substitute(line, '__restore__', a:group, 'g')
|
||||||
|
|
||||||
|
let self._line .= line
|
||||||
let self._curgroup = a:group
|
let self._curgroup = a:group
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ function! s:create(parts, append)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let val .= partval
|
let val .= partval
|
||||||
|
if exists('part.accent')
|
||||||
|
let val .= '%#__restore__#'
|
||||||
|
endif
|
||||||
let _ .= val
|
let _ .= val
|
||||||
endfor
|
endfor
|
||||||
return _
|
return _
|
||||||
|
@ -44,6 +44,19 @@ describe 'active builder'
|
|||||||
let stl = s:builder.build()
|
let stl = s:builder.build()
|
||||||
Expect stl == '%#Normal#%#Normal_foo#hello'
|
Expect stl == '%#Normal#%#Normal_foo#hello'
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'inactive builder'
|
describe 'inactive builder'
|
||||||
|
@ -28,7 +28,7 @@ describe 'init'
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'section c should be file'
|
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
|
end
|
||||||
|
|
||||||
it 'section x should be filetype'
|
it 'section x should be filetype'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user