@@ -27,10 +27,25 @@ import { LanguageClient, State as ClientState } from 'vscode-languageclient'
27
27
28
28
const fileExists = util . promisify ( fs . exists )
29
29
30
- function configValueToString ( value : unknown ) : string {
30
+ function configValueToString (
31
+ value : unknown ,
32
+ asTooltip : boolean = false
33
+ ) : string {
34
+ if ( value === null ) {
35
+ return 'null'
36
+ }
37
+ if ( typeof value === 'undefined' ) {
38
+ return asTooltip ? '(undefined)' : ''
39
+ }
31
40
if ( Array . isArray ( value ) ) {
41
+ if ( asTooltip && value . length === 0 ) {
42
+ return '(empty array)'
43
+ }
32
44
return value . join ( ', ' )
33
45
}
46
+ if ( asTooltip && value === '' ) {
47
+ return '(empty string)'
48
+ }
34
49
return value . toString ( )
35
50
}
36
51
@@ -47,6 +62,7 @@ type ConfigItemParams = {
47
62
iconPath ?: string | ThemeIcon
48
63
command ?: Command
49
64
contextValue ?: string
65
+ tooltip ?: string
50
66
}
51
67
52
68
class ConfigItem extends TreeItem {
@@ -67,6 +83,7 @@ class ConfigItem extends TreeItem {
67
83
iconPath,
68
84
command,
69
85
contextValue,
86
+ tooltip,
70
87
} : ConfigItemParams ) {
71
88
super ( label , collapsibleState )
72
89
this . key = key
@@ -76,6 +93,7 @@ class ConfigItem extends TreeItem {
76
93
this . command = command
77
94
this . contextValue = contextValue
78
95
this . workspace = workspace
96
+ this . tooltip = tooltip
79
97
}
80
98
}
81
99
@@ -346,6 +364,9 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
346
364
description : isExpandable
347
365
? undefined
348
366
: configValueToString ( config [ key ] ) ,
367
+ tooltip : isExpandable
368
+ ? undefined
369
+ : configValueToString ( config [ key ] , true ) ,
349
370
contextValue : location ? 'revealable' : undefined ,
350
371
workspace,
351
372
} )
@@ -360,16 +381,20 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
360
381
let { plugins, config } = this . workspaces [ element . workspace ]
361
382
362
383
if ( element . key . length === 1 && element . key [ 0 ] === 'plugins' ) {
363
- return plugins . map ( ( plugin , i ) => ( {
364
- label : plugin . name || '(anonymous)' ,
365
- description : plugin . version ? `v${ plugin . version } ` : undefined ,
366
- key : [ 'plugins' , i . toString ( ) ] ,
367
- workspace : element . workspace ,
368
- tooltip : plugin . description ,
369
- contextValue : plugin . homepage
370
- ? `plugin:${ plugin . homepage } `
371
- : undefined ,
372
- } ) )
384
+ return plugins . map (
385
+ ( plugin , i ) =>
386
+ new ConfigItem ( {
387
+ label : plugin . name || '(anonymous)' ,
388
+ description : plugin . version ? `v${ plugin . version } ` : undefined ,
389
+ key : [ 'plugins' , i . toString ( ) ] ,
390
+ workspace : element . workspace ,
391
+ tooltip : plugin . description ,
392
+ contextValue : plugin . homepage
393
+ ? `plugin:${ plugin . homepage } `
394
+ : undefined ,
395
+ collapsibleState : TreeItemCollapsibleState . None ,
396
+ } )
397
+ )
373
398
}
374
399
375
400
let item = dlv ( config , element . key )
@@ -389,6 +414,9 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
389
414
description : isExpandable
390
415
? undefined
391
416
: configValueToString ( item [ key ] ) ,
417
+ tooltip : isExpandable
418
+ ? undefined
419
+ : configValueToString ( item [ key ] , true ) ,
392
420
contextValue : location ? 'revealable' : undefined ,
393
421
workspace : element . workspace ,
394
422
} )
0 commit comments