mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-01-23 04:44:16 +08:00
Merge pull request #1223 from chrisbra/fix_prepend_sep
don't add a second separator if not needed
This commit is contained in:
commit
168b18ff0a
|
@ -17,6 +17,7 @@ function! s:create(parts, append)
|
||||||
for idx in range(len(a:parts))
|
for idx in range(len(a:parts))
|
||||||
let part = airline#parts#get(a:parts[idx])
|
let part = airline#parts#get(a:parts[idx])
|
||||||
let val = ''
|
let val = ''
|
||||||
|
let add_sep = get(l:, 'add_sep', 0)
|
||||||
|
|
||||||
if exists('part.function')
|
if exists('part.function')
|
||||||
let func = (part.function).'()'
|
let func = (part.function).'()'
|
||||||
|
@ -27,7 +28,11 @@ function! s:create(parts, append)
|
||||||
let val .= s:spc.g:airline_left_alt_sep.s:spc
|
let val .= s:spc.g:airline_left_alt_sep.s:spc
|
||||||
endif
|
endif
|
||||||
if a:append < 0 && idx != 0
|
if a:append < 0 && idx != 0
|
||||||
let val = s:spc.g:airline_right_alt_sep.s:spc.val
|
let t = ''
|
||||||
|
if !add_sep
|
||||||
|
let t = s:spc.g:airline_right_alt_sep.s:spc
|
||||||
|
endif
|
||||||
|
let val = t.val
|
||||||
endif
|
endif
|
||||||
if exists('part.raw')
|
if exists('part.raw')
|
||||||
let _ .= s:wrap_accent(part, val.(part.raw))
|
let _ .= s:wrap_accent(part, val.(part.raw))
|
||||||
|
@ -42,10 +47,15 @@ function! s:create(parts, append)
|
||||||
|
|
||||||
if a:append > 0 && idx != 0
|
if a:append > 0 && idx != 0
|
||||||
let partval = printf('%%{airline#util#append(%s,%s)}', func, minwidth)
|
let partval = printf('%%{airline#util#append(%s,%s)}', func, minwidth)
|
||||||
|
" will add an extra separator, if minwidth is zero
|
||||||
|
let add_sep = (minwidth == 0)
|
||||||
elseif a:append < 0 && idx != len(a:parts) - 1
|
elseif a:append < 0 && idx != len(a:parts) - 1
|
||||||
let partval = printf('%%{airline#util#prepend(%s,%s)}', func, minwidth)
|
let partval = printf('%%{airline#util#prepend(%s,%s)}', func, minwidth)
|
||||||
|
" will add an extra separator, if minwidth is zero
|
||||||
|
let add_sep = (minwidth == 0)
|
||||||
else
|
else
|
||||||
let partval = printf('%%{airline#util#wrap(%s,%s)}', func, minwidth)
|
let partval = printf('%%{airline#util#wrap(%s,%s)}', func, minwidth)
|
||||||
|
let add_sep = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('part.condition')
|
if exists('part.condition')
|
||||||
|
|
|
@ -72,5 +72,10 @@ describe 'section'
|
||||||
let s = airline#section#create(['conditional'])
|
let s = airline#section#create(['conditional'])
|
||||||
Expect s == '%{0 ? airline#util#wrap("conditional",0) : ""}'
|
Expect s == '%{0 ? airline#util#wrap("conditional",0) : ""}'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should not draw two separators after another'
|
||||||
|
let s = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
|
||||||
|
Expect s == '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user