22" Filename: autoload/lightline.vim
33" Author: itchyny
44" License: MIT License
5- " Last Change: 2021/11/21 22:54:46 .
5+ " Last Change: 2024/12/30 21:33:02 .
66" =============================================================================
77
88let s: save_cpo = &cpo
@@ -317,26 +317,13 @@ function! lightline#statusline(inactive) abort
317317 return s: line (0 , a: inactive )
318318endfunction
319319
320- function ! s: normalize (result) abort
321- if type (a: result ) == 3
322- return map (a: result , ' type(v:val) == 1 ? v:val : string(v:val)' )
323- elseif type (a: result ) == 1
324- return [a: result ]
325- else
326- return [string (a: result )]
327- endif
328- endfunction
329-
330320function ! s: evaluate_expand (component) abort
331- try
332- let result = eval (a: component . ' ()' )
333- if type (result) == 1 && result == # ' '
334- return []
335- endif
336- catch
337- return []
338- endtry
339- return map (type (result) == 3 ? (result + [[], [], []])[:2 ] : [[], [result], []], ' filter(s:normalize(v:val), "v:val !=# '''' ")' )
321+ try | let value = eval (a: component . ' ()' ) | catch | return [] | endtry
322+ return value is ' ' ? [] :
323+ \ map (type (value) == 3 ? value : [[], [value], []],
324+ \ 'filter (map (type (v: val ) == 3 ? v: val : [v: val ],
325+ \ " type(v:val) == 1 ? v:val : string(v:val)" ),
326+ \ " v:val !=# ''''" )')
340327endfunction
341328
342329function ! s: convert (name, index ) abort
@@ -346,7 +333,8 @@ function! s:convert(name, index) abort
346333 let type = get (s: lightline .component_type, a: name , a: index )
347334 let is_raw = get (s: lightline .component_raw, a: name ) || type == # ' raw'
348335 return filter (map (s: evaluate_expand (s: lightline .component_expand[a: name ]),
349- \ ' [v:val, 1 + ' . is_raw . ' , v:key == 1 && ' . (type !=# ' raw' ) . ' ? "' . type . ' " : "' . a: index . ' ", "' . a: index . ' "]' ), ' v:val[0] != []' )
336+ \ ' [v:val, 1 + ' . is_raw . ' , v:key == 1 && ' . (type !=# ' raw' ) .
337+ \ ' ? "' . type . ' " : "' . a: index . ' ", "' . a: index . ' "]' ), ' v:val[0] != []' )
350338 endif
351339endfunction
352340
0 commit comments