Skip to content

Commit 413de96

Browse files
committed
Update explorer tooltips
1 parent 0d03c52 commit 413de96

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

src/lib/configExplorer.ts

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,25 @@ import { LanguageClient, State as ClientState } from 'vscode-languageclient'
2727

2828
const fileExists = util.promisify(fs.exists)
2929

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+
}
3140
if (Array.isArray(value)) {
41+
if (asTooltip && value.length === 0) {
42+
return '(empty array)'
43+
}
3244
return value.join(', ')
3345
}
46+
if (asTooltip && value === '') {
47+
return '(empty string)'
48+
}
3449
return value.toString()
3550
}
3651

@@ -47,6 +62,7 @@ type ConfigItemParams = {
4762
iconPath?: string | ThemeIcon
4863
command?: Command
4964
contextValue?: string
65+
tooltip?: string
5066
}
5167

5268
class ConfigItem extends TreeItem {
@@ -67,6 +83,7 @@ class ConfigItem extends TreeItem {
6783
iconPath,
6884
command,
6985
contextValue,
86+
tooltip,
7087
}: ConfigItemParams) {
7188
super(label, collapsibleState)
7289
this.key = key
@@ -76,6 +93,7 @@ class ConfigItem extends TreeItem {
7693
this.command = command
7794
this.contextValue = contextValue
7895
this.workspace = workspace
96+
this.tooltip = tooltip
7997
}
8098
}
8199

@@ -346,6 +364,9 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
346364
description: isExpandable
347365
? undefined
348366
: configValueToString(config[key]),
367+
tooltip: isExpandable
368+
? undefined
369+
: configValueToString(config[key], true),
349370
contextValue: location ? 'revealable' : undefined,
350371
workspace,
351372
})
@@ -360,16 +381,20 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
360381
let { plugins, config } = this.workspaces[element.workspace]
361382

362383
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+
)
373398
}
374399

375400
let item = dlv(config, element.key)
@@ -389,6 +414,9 @@ export class TailwindDataProvider implements TreeDataProvider<ConfigItem> {
389414
description: isExpandable
390415
? undefined
391416
: configValueToString(item[key]),
417+
tooltip: isExpandable
418+
? undefined
419+
: configValueToString(item[key], true),
392420
contextValue: location ? 'revealable' : undefined,
393421
workspace: element.workspace,
394422
})

0 commit comments

Comments
 (0)