Skip to content

Commit

Permalink
fix: icon contributes (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaaaash authored Mar 25, 2022
1 parent 8b85ed6 commit a474f8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/extension/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export interface IExtension extends IExtensionProps {
toJSON(): IExtensionProps;
}

const VAR_REGEXP = /\$\(.*?\)/g;
const VAR_REGEXP = /^\$\(([a-z.]+\/)?([a-z-]+)(~[a-z]+)?\)$/i;

// VSCode Types
export abstract class VSCodeContributePoint<T extends JSONType = JSONType> extends Disposable {
Expand All @@ -264,15 +264,10 @@ export abstract class VSCodeContributePoint<T extends JSONType = JSONType> exten
abstract contribute();

protected toIconClass(iconContrib: { [index in ThemeType]: string } | string): string | undefined {
if (typeof iconContrib === 'object') {
const iconClass = this.iconService?.fromIcon(this.extension.path, iconContrib, IconType.Background);
return iconClass;
if (typeof iconContrib === 'string' && VAR_REGEXP.test(iconContrib)) {
return this.iconService?.fromString(iconContrib);
}
const parsedName = VAR_REGEXP.exec(iconContrib);
if (parsedName && parsedName[1]) {
return this.iconService?.fromString(parsedName[1]);
}
return this.iconService?.fromString(iconContrib);
return this.iconService?.fromIcon(this.extension.path, iconContrib, IconType.Mask);
}

protected getLocalizeFromNlsJSON(title: string): string {
Expand Down
1 change: 1 addition & 0 deletions packages/startup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"**/__tests__/**",
"**/src/browser/**",
"**/core-browser/**",
"**/extensions/common/**",
"**/theme/**",
"**/src/hosted/**",
"**/*.d.ts"
Expand Down

0 comments on commit a474f8c

Please sign in to comment.