fix highlighting separator when component group is skipped due to expanding components (close #289, #290)

This commit is contained in:
itchyny
2018-09-16 23:12:53 +09:00
parent 166f179cf8
commit c9263d945e
2 changed files with 23 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2018/06/22 08:50:00.
" Last Change: 2018/09/16 23:00:00.
" =============================================================================
let s:save_cpo = &cpo
@@ -343,9 +343,9 @@ function! s:convert(name, index) abort
let type = get(s:lightline.component_type, a:name, a:index)
let is_raw = get(s:lightline.component_raw, a:name) || type ==# 'raw'
return filter(s:map(s:evaluate_expand(s:lightline.component_expand[a:name]),
\ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . ' ? "' . type . '" : "' . a:index . '"]'), 'v:val[0] != []')
\ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . ' ? "' . type . '" : "' . a:index . '", "' . a:index . '"]'), 'v:val[0] != []')
else
return [[[a:name], 0, a:index]]
return [[[a:name], 0, a:index, a:index]]
endif
endfunction
@@ -375,16 +375,23 @@ function! s:expand(components) abort
let components = []
let expanded = []
let indices = []
let prevtype = ''
let previndex = -1
let xs = s:flatten_twice(s:map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, ''" . v:key . "'')")'))
for [component, expand, index] in xs
if previndex != index
call add(indices, index)
for [component, expand, type, index] in xs
if prevtype !=# type
for i in range(previndex + 1, max([previndex, index - 1]))
call add(indices, string(i))
call add(components, [])
call add(expanded, [])
endfor
call add(indices, type)
call add(components, [])
call add(expanded, [])
endif
call extend(components[-1], component)
call extend(expanded[-1], repeat([expand], len(component)))
let prevtype = type
let previndex = index
endfor
call add(indices, string(len(a:components)))