Merge pull request #1250 from chrisbra/1233

Do not unconditionally modify airline_c_inactive
This commit is contained in:
Christian Brabandt 2016-09-08 21:30:20 +02:00 committed by GitHub
commit afee79bbe0
3 changed files with 13 additions and 4 deletions

View File

@ -188,7 +188,7 @@ function! airline#check_mode(winnr)
let mode_string = join(l:mode) let mode_string = join(l:mode)
if get(w:, 'airline_lastmode', '') != mode_string if get(w:, 'airline_lastmode', '') != mode_string
call airline#highlighter#highlight_modified_inactive(context.bufnr) call airline#highlighter#highlight_modified_inactive(context.bufnr)
call airline#highlighter#highlight(l:mode) call airline#highlighter#highlight(l:mode, context.bufnr)
let w:airline_lastmode = mode_string let w:airline_lastmode = mode_string
endif endif

View File

@ -47,6 +47,9 @@ function! s:prototype.build()
let contents = section[1] let contents = section[1]
let pgroup = prev_group let pgroup = prev_group
let prev_group = s:get_prev_group(self._sections, i) let prev_group = s:get_prev_group(self._sections, i)
if group ==# 'airline_c' && !self._context.active
let group = 'airline_c'. self._context.bufnr
endif
if is_empty if is_empty
let prev_group = pgroup let prev_group = pgroup
endif endif
@ -87,6 +90,7 @@ function! s:prototype.build()
endwhile endwhile
if !self._context.active if !self._context.active
"let line = substitute(line, '%#airline_c#', '%#airline_c'.self._context.bufnr.'#', '')
let line = substitute(line, '%#.\{-}\ze#', '\0_inactive', 'g') let line = substitute(line, '%#.\{-}\ze#', '\0_inactive', 'g')
endif endif
return line return line

View File

@ -136,7 +136,8 @@ function! airline#highlighter#highlight_modified_inactive(bufnr)
endif endif
endfunction endfunction
function! airline#highlighter#highlight(modes) function! airline#highlighter#highlight(modes, ...)
let bufnr = a:0 ? a:1 : ''
let p = g:airline#themes#{g:airline_theme}#palette let p = g:airline#themes#{g:airline_theme}#palette
" draw the base mode, followed by any overrides " draw the base mode, followed by any overrides
@ -147,7 +148,11 @@ function! airline#highlighter#highlight(modes)
let dict = g:airline#themes#{g:airline_theme}#palette[mode] let dict = g:airline#themes#{g:airline_theme}#palette[mode]
for kvp in items(dict) for kvp in items(dict)
let mode_colors = kvp[1] let mode_colors = kvp[1]
call airline#highlighter#exec(kvp[0].suffix, mode_colors) let name = kvp[0]
if name is# 'airline_c' && !empty(bufnr) && suffix is# '_inactive'
let name = 'airline_c'.bufnr
endif
call airline#highlighter#exec(name.suffix, mode_colors)
for accent in keys(s:accents) for accent in keys(s:accents)
if !has_key(p.accents, accent) if !has_key(p.accents, accent)
@ -165,7 +170,7 @@ function! airline#highlighter#highlight(modes)
else else
call add(colors, get(p.accents[accent], 4, '')) call add(colors, get(p.accents[accent], 4, ''))
endif endif
call airline#highlighter#exec(kvp[0].suffix.'_'.accent, colors) call airline#highlighter#exec(name.suffix.'_'.accent, colors)
endfor endfor
endfor endfor