Skip to content

Commit

Permalink
Closes #85624 - adds codicons to custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Amodio committed Nov 26, 2019
1 parent 9b537ca commit c596ef0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/vs/workbench/browser/parts/views/customView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list
import { ITreeRenderer, ITreeNode, IAsyncDataSource, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree';
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { escape, isFalsyOrWhitespace } from 'vs/base/common/strings';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';

export class CustomTreeViewPane extends ViewletPane {
Expand Down Expand Up @@ -796,9 +796,26 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
templateData.resourceLabel.setResource({ name: label, description }, { title, hideIcon: true, extraClasses: ['custom-view-tree-node-item-resourceLabel'], matches: matches ? matches : createMatches(element.filterData) });
}

templateData.icon.style.backgroundImage = iconUrl ? DOM.asCSSUrl(iconUrl) : '';
templateData.icon.title = title ? title : '';
DOM.toggleClass(templateData.icon, 'custom-view-tree-node-item-icon', !!iconUrl);

let codicon: string | undefined;
if (iconUrl?.scheme === 'icon' && iconUrl?.authority === 'vscode.codicons') {
codicon = `codicon-${escape(iconUrl.path.substr(1))}`;
}

DOM.toggleClass(templateData.icon, 'codicon', !!codicon);
templateData.icon.classList.forEach((cls, i, list) => {
if (cls !== codicon && cls.indexOf('codicon-') === 0) {
list.remove(cls);
}
});
if (codicon) {
DOM.addClass(templateData.icon, codicon);
}

templateData.icon.style.backgroundImage = iconUrl && !codicon ? DOM.asCSSUrl(iconUrl) : '';

templateData.actionBar.context = <TreeViewItemHandleArg>{ $treeViewId: this.treeViewId, $treeItemHandle: node.handle };
templateData.actionBar.push(this.menus.getResourceActions(node), { icon: true, label: false });
if (this._actionRunner) {
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/browser/parts/views/media/views.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
-moz-osx-font-smoothing: grayscale;
}

.customview-tree .monaco-list .monaco-list-row .custom-view-tree-node-item > .custom-view-tree-node-item-icon.codicon {
margin-top: 3px;
}

.customview-tree .monaco-list .monaco-list-row .custom-view-tree-node-item .custom-view-tree-node-item-resourceLabel .monaco-icon-label-description-container {
flex: 1;
}
Expand Down

0 comments on commit c596ef0

Please sign in to comment.