Skip to content

Commit 055bc4f

Browse files
authored
References view shows icons even though I have icons disabled (microsoft#151420)
Fixes microsoft#151406
1 parent ecdf007 commit 055bc4f

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/vs/workbench/browser/parts/views/treeView.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import { Extensions, ITreeItem, ITreeItemLabel, ITreeView, ITreeViewDataProvider
6464
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
6565
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
6666
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
67-
import { ThemeSettings } from 'vs/workbench/services/themes/common/workbenchThemeService';
6867
import { ITreeViewsService } from 'vs/workbench/services/views/browser/treeViewsService';
6968
import { CodeDataTransfers } from 'vs/platform/dnd/browser/dnd';
7069
import { createFileDataTransferItemFromFile } from 'vs/editor/browser/dnd';
@@ -1016,7 +1015,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
10161015
return ({ start, end });
10171016
}) : undefined;
10181017
const icon = this.themeService.getColorTheme().type === ColorScheme.LIGHT ? node.icon : node.iconDark;
1019-
const iconUrl = icon ? URI.revive(icon) : null;
1018+
const iconUrl = icon ? URI.revive(icon) : undefined;
10201019
const title = this.getHover(label, resource, node);
10211020

10221021
// reset
@@ -1029,7 +1028,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
10291028
templateData.resourceLabel.setResource({ name: label, description, resource: labelResource }, {
10301029
fileKind: this.getFileKind(node),
10311030
title,
1032-
hideIcon: !!iconUrl || this.shouldShowThemeIcon(!!resource, node.themeIcon),
1031+
hideIcon: this.shouldHideResourceLabelIcon(iconUrl, node.themeIcon),
10331032
fileDecorations,
10341033
extraClasses: ['custom-view-tree-node-item-resourceLabel'],
10351034
matches: matches ? matches : createMatches(element.filterData),
@@ -1050,8 +1049,6 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
10501049
templateData.icon.style.backgroundImage = DOM.asCSSUrl(iconUrl);
10511050
} else {
10521051
let iconClass: string | undefined;
1053-
// If there is a resource for this tree item then we should respect the file icon theme's choice about
1054-
// whether to show a folder icon.
10551052
if (this.shouldShowThemeIcon(!!resource, node.themeIcon)) {
10561053
iconClass = ThemeIcon.asClassName(node.themeIcon);
10571054
if (node.themeIcon.color) {
@@ -1084,25 +1081,20 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
10841081
container.parentElement!.classList.toggle('align-icon-with-twisty', this.aligner.alignIconWithTwisty(treeItem));
10851082
}
10861083

1084+
private shouldHideResourceLabelIcon(iconUrl: URI | undefined, icon: ThemeIcon | undefined): boolean {
1085+
// We always hide the resource label in favor of the iconUrl when it's provided.
1086+
// When `ThemeIcon` is provided, we hide the resource label icon in favor of it only if it's a not a file icon.
1087+
return !!iconUrl || !this.isFileKindThemeIcon(icon);
1088+
}
1089+
10871090
private shouldShowThemeIcon(hasResource: boolean, icon: ThemeIcon | undefined): icon is ThemeIcon {
10881091
if (!icon) {
10891092
return false;
10901093
}
10911094

1092-
if (hasResource && this.isFileKindThemeIcon(icon)) {
1093-
return !this.shouldShowFileIcons();
1094-
} else if (hasResource && this.isFolderThemeIcon(icon)) {
1095-
return !this.shouldShowFolderIcons();
1096-
}
1097-
return true;
1098-
}
1099-
1100-
private shouldShowFileIcons(): boolean {
1101-
return this.configurationService.getValue(ThemeSettings.FILE_ICON_THEME);
1102-
}
1103-
1104-
private shouldShowFolderIcons(): boolean {
1105-
return this.themeService.getFileIconTheme().hasFolderIcons && this.shouldShowFileIcons();
1095+
// If there's a resource and the icon is a file icon, then the icon (or lack thereof) will already be coming from the
1096+
// icon theme and should use whatever the icon theme has provided.
1097+
return !(hasResource && this.isFileKindThemeIcon(icon));
11061098
}
11071099

11081100
private isFolderThemeIcon(icon: ThemeIcon | undefined): boolean {

0 commit comments

Comments
 (0)