@@ -49,21 +49,22 @@ export class LSPCompletionRenderer
49
49
) ;
50
50
}
51
51
52
- protected getExtraInfo ( item : CompletionItem ) : string {
52
+ protected getExtraInfo (
53
+ item : CompletionItem | IExtendedCompletionItem
54
+ ) : string | undefined {
53
55
const labelExtra = this . options . settings . composite . labelExtra ;
56
+ const detail = 'detail' in item ? item ?. detail ?? '' : '' ;
54
57
switch ( labelExtra ) {
55
58
case 'detail' :
56
- return item ?. detail || '' ;
59
+ return detail ;
57
60
case 'type' :
58
61
return item ?. type ?. toLowerCase ?.( ) ;
59
62
case 'source' :
60
63
return item ?. source ;
61
64
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 ] ;
67
68
default :
68
69
this . options . console . warn (
69
70
'labelExtra does not match any of the expected values' ,
@@ -73,7 +74,10 @@ export class LSPCompletionRenderer
73
74
}
74
75
}
75
76
76
- public updateExtraInfo ( item : CompletionItem , li : HTMLLIElement ) {
77
+ public updateExtraInfo (
78
+ item : CompletionItem | IExtendedCompletionItem ,
79
+ li : HTMLLIElement
80
+ ) {
77
81
const extraText = this . getExtraInfo ( item ) ;
78
82
if ( extraText ) {
79
83
const extraElement = li . getElementsByClassName ( this . EXTRA_INFO_CLASS ) [ 0 ] ;
@@ -184,10 +188,11 @@ export class LSPCompletionRenderer
184
188
}
185
189
}
186
190
187
- itemWidthHeuristic ( item : CompletionItem ) : number {
191
+ itemWidthHeuristic ( item : CompletionItem | IExtendedCompletionItem ) : number {
188
192
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 ( ) ;
191
196
if ( type === 'file' || type === 'path' ) {
192
197
// account for elision
193
198
const parts = item . label . split ( / < \/ m a r k > / g) ;
0 commit comments