Merge pull request #111 from bootleq/blank-section

Do not render spare spaces for empty sections.
This commit is contained in:
Bailey Ling 2013-08-02 20:48:24 -07:00
commit 1d07110af3

View File

@ -93,8 +93,10 @@ function! s:getwinvar(winnr, key, ...)
return get(winvals, a:key, (a:0 ? a:1 : '')) return get(winvals, a:key, (a:0 ? a:1 : ''))
endfunction endfunction
function! s:get_section(winnr, key) function! s:get_section(winnr, key, ...)
return s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) let text = s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key})
let [prefix, suffix] = [get(a:000, 0, ' '), get(a:000, 1, ' ')]
return empty(text) ? '' : prefix.text.suffix
endfunction endfunction
function! s:get_statusline(winnr, active) function! s:get_statusline(winnr, active)
@ -107,15 +109,15 @@ function! s:get_statusline(winnr, active)
let sl = '%{airline#update_highlight()}' let sl = '%{airline#update_highlight()}'
if a:active || s:getwinvar(a:winnr, 'airline_left_only', 0) if a:active || s:getwinvar(a:winnr, 'airline_left_only', 0)
let sl.=l:mode_color.' '.s:get_section(a:winnr, 'a').' ' let sl.=l:mode_color.s:get_section(a:winnr, 'a')
let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}' let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}'
let sl.=l:mode_sep_color let sl.=l:mode_sep_color
let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep
let sl.=l:info_color let sl.=l:info_color
let sl.=' '.s:get_section(a:winnr, 'b').' ' let sl.=s:get_section(a:winnr, 'b')
let sl.=l:info_sep_color let sl.=l:info_sep_color
let sl.=g:airline_left_sep let sl.=g:airline_left_sep
let sl.=l:status_color.' %<'.s:get_section(a:winnr, 'c').' ' let sl.=l:status_color.s:get_section(a:winnr, 'c', ' %<')
let gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', '')) let gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', ''))
let sl.=gutter != '' let sl.=gutter != ''
\ ? gutter \ ? gutter
@ -125,15 +127,15 @@ function! s:get_statusline(winnr, active)
endif endif
if !s:getwinvar(a:winnr, 'airline_left_only', 0) if !s:getwinvar(a:winnr, 'airline_left_only', 0)
let sl.='%=' let sl.='%='
let sl.=' '.s:get_section(a:winnr, 'x').' ' let sl.=s:get_section(a:winnr, 'x')
let sl.=l:info_sep_color let sl.=l:info_sep_color
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
let sl.=l:info_color let sl.=l:info_color
let sl.=' '.s:get_section(a:winnr, 'y').' ' let sl.=s:get_section(a:winnr, 'y')
let sl.=l:mode_sep_color let sl.=l:mode_sep_color
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
let sl.=l:mode_color let sl.=l:mode_color
let sl.=' '.s:get_section(a:winnr, 'z').' ' let sl.=s:get_section(a:winnr, 'z')
endif endif
return sl return sl
endfunction endfunction