diff --git a/autoload/lightline.vim b/autoload/lightline.vim index edcae03..ca4c9dd 100644 --- a/autoload/lightline.vim +++ b/autoload/lightline.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2018/09/16 23:00:00. +" Last Change: 2018/09/17 12:00:00. " ============================================================================= let s:save_cpo = &cpo @@ -394,6 +394,11 @@ function! s:expand(components) abort let prevtype = type let previndex = index endfor + for i in range(previndex + 1, max([previndex, len(a:components) - 1])) + call add(indices, string(i)) + call add(components, []) + call add(expanded, []) + endfor call add(indices, string(len(a:components))) return [components, expanded, indices] endfunction diff --git a/test/expand.vim b/test/expand.vim index 0a132e2..3bd4a6b 100644 --- a/test/expand.vim +++ b/test/expand.vim @@ -507,6 +507,22 @@ function! s:suite.custom_type_notfound() \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) endfunction +function! s:suite.duplicated_string() + function! Custom() + return 'custom' + endfunction + function! Modified() + return '' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom', 'modified': 'Modified' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['custom', 'custom'], []], [[0], [1, 1], []], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'custom', 'custom']], [[0, 1, 1]], ['0', '1']]) + delfunction Custom +endfunction + function! s:suite.duplicated_left_nil() function! Custom() return [ [], ['y0', 'y1'], ['z0', 'z1'] ]