Skip to content

Commit

Permalink
Closes #84695 - adds codicons to menu commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Amodio committed Nov 26, 2019
1 parent a8158ae commit d12aa5f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/vs/workbench/api/common/menusExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { escape, isFalsyOrWhitespace } from 'vs/base/common/strings';
import * as resources from 'vs/base/common/resources';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { forEach } from 'vs/base/common/collections';
Expand Down Expand Up @@ -347,10 +347,16 @@ commandsExtensionPoint.setHandler(extensions => {

const { icon, enablement, category, title, command } = userFriendlyCommand;

let iconClassName: string | undefined;
let absoluteIcon: { dark: URI; light?: URI; } | undefined;
if (icon) {
if (typeof icon === 'string') {
absoluteIcon = { dark: resources.joinPath(extension.description.extensionLocation, icon) };
if (icon.indexOf('icon://vscode.codicons/') === 0) {
iconClassName = escape(`codicon-${URI.parse(icon).path.substr(1)}`);
}
else {
absoluteIcon = { dark: resources.joinPath(extension.description.extensionLocation, icon) };
}
} else {
absoluteIcon = {
dark: resources.joinPath(extension.description.extensionLocation, icon.dark),
Expand All @@ -367,7 +373,8 @@ commandsExtensionPoint.setHandler(extensions => {
title,
category,
precondition: ContextKeyExpr.deserialize(enablement),
iconLocation: absoluteIcon
iconLocation: absoluteIcon,
iconClassName: iconClassName
});
_commandRegistrations.add(registration);
}
Expand Down

0 comments on commit d12aa5f

Please sign in to comment.