@@ -49,21 +49,22 @@ export class LSPCompletionRenderer
4949 ) ;
5050 }
5151
52- protected getExtraInfo ( item : CompletionItem ) : string {
52+ protected getExtraInfo (
53+ item : CompletionItem | IExtendedCompletionItem
54+ ) : string | undefined {
5355 const labelExtra = this . options . settings . composite . labelExtra ;
56+ const detail = 'detail' in item ? item ?. detail ?? '' : '' ;
5457 switch ( labelExtra ) {
5558 case 'detail' :
56- return item ?. detail || '' ;
59+ return detail ;
5760 case 'type' :
5861 return item ?. type ?. toLowerCase ?.( ) ;
5962 case 'source' :
6063 return item ?. source ;
6164 case 'auto' :
62- return [
63- item ?. detail || '' ,
64- item ?. type ?. toLowerCase ?.( ) ,
65- item ?. source
66- ] . filter ( x => ! ! x ) [ 0 ] ;
65+ return [ detail , item ?. type ?. toLowerCase ?.( ) , item ?. source ] . filter (
66+ x => ! ! x
67+ ) [ 0 ] ;
6768 default :
6869 this . options . console . warn (
6970 'labelExtra does not match any of the expected values' ,
@@ -73,7 +74,10 @@ export class LSPCompletionRenderer
7374 }
7475 }
7576
76- public updateExtraInfo ( item : CompletionItem , li : HTMLLIElement ) {
77+ public updateExtraInfo (
78+ item : CompletionItem | IExtendedCompletionItem ,
79+ li : HTMLLIElement
80+ ) {
7781 const extraText = this . getExtraInfo ( item ) ;
7882 if ( extraText ) {
7983 const extraElement = li . getElementsByClassName ( this . EXTRA_INFO_CLASS ) [ 0 ] ;
@@ -184,10 +188,11 @@ export class LSPCompletionRenderer
184188 }
185189 }
186190
187- itemWidthHeuristic ( item : CompletionItem ) : number {
191+ itemWidthHeuristic ( item : CompletionItem | IExtendedCompletionItem ) : number {
188192 let labelSize = item . label . replace ( / < ( \/ ) ? m a r k > / g, '' ) . length ;
189- const extraTextSize = this . getExtraInfo ( item ) . length ;
190- const type = item . type . toLowerCase ( ) ;
193+ const extra = this . getExtraInfo ( item ) ;
194+ const extraTextSize = extra ?. length ?? 0 ;
195+ const type = item . type ?. toLowerCase ( ) ;
191196 if ( type === 'file' || type === 'path' ) {
192197 // account for elision
193198 const parts = item . label . split ( / < \/ m a r k > / g) ;
0 commit comments