Skip to content

Commit

Permalink
also support single icon, not just ThemeIcon and {light, dark}-tuples,
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Feb 19, 2020
1 parent cc4b95f commit 3e21159
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ export interface WorkspaceEditMetadata {
needsConfirmation: boolean;
label: string;
description?: string;
iconPath?: { id: string } | { light: URI, dark: URI };
iconPath?: { id: string } | URI | { light: URI, dark: URI };
}

export interface WorkspaceFileEditOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6044,7 +6044,7 @@ declare namespace monaco.languages {
description?: string;
iconPath?: {
id: string;
} | {
} | Uri | {
light: Uri;
dark: Uri;
};
Expand Down
15 changes: 13 additions & 2 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { ExtensionActivationReason } from 'vs/workbench/api/common/extHostExtens
import { TunnelDto } from 'vs/workbench/api/common/extHostTunnelService';
import { TunnelOptions } from 'vs/platform/remote/common/tunnel';
import { Timeline, TimelineChangeEvent, TimelineCursor, TimelineProviderDescriptor } from 'vs/workbench/contrib/timeline/common/timeline';
import { revive } from 'vs/base/common/marshalling';

export interface IEnvironment {
isExtensionDevelopmentDebug: boolean;
Expand Down Expand Up @@ -1093,18 +1094,25 @@ export interface IWorkspaceSymbolsDto extends IdObject {
symbols: IWorkspaceSymbolDto[];
}

export interface IWorkspaceEditEntryMetadataDto {
needsConfirmation: boolean;
label: string;
description?: string;
iconPath?: { id: string } | UriComponents | { light: UriComponents, dark: UriComponents };
}

export interface IWorkspaceFileEditDto {
oldUri?: UriComponents;
newUri?: UriComponents;
options?: modes.WorkspaceFileEditOptions
metadata?: modes.WorkspaceEditMetadata;
metadata?: IWorkspaceEditEntryMetadataDto;
}

export interface IWorkspaceTextEditDto {
resource: UriComponents;
edit: modes.TextEdit;
modelVersionId?: number;
metadata?: modes.WorkspaceEditMetadata;
metadata?: IWorkspaceEditEntryMetadataDto;
}

export interface IWorkspaceEditDto {
Expand All @@ -1123,6 +1131,9 @@ export function reviveWorkspaceEditDto(data: IWorkspaceEditDto | undefined): mod
(<IWorkspaceFileEditDto>edit).newUri = URI.revive((<IWorkspaceFileEditDto>edit).newUri);
(<IWorkspaceFileEditDto>edit).oldUri = URI.revive((<IWorkspaceFileEditDto>edit).oldUri);
}
if (edit.metadata && edit.metadata.iconPath) {
edit.metadata = revive(edit.metadata);
}
}
}
return <modes.WorkspaceEdit>data;
Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/contrib/bulkEdit/browser/bulkEditTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { basename } from 'vs/base/common/resources';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { WorkspaceFileEdit } from 'vs/editor/common/modes';
import { compare } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';

// --- VIEW MODEL

Expand Down Expand Up @@ -420,6 +421,12 @@ export class CategoryElementRenderer implements ITreeRenderer<CategoryElement, F
const className = ThemeIcon.asClassName(metadata.iconPath);
template.icon.className = className ? `theme-icon ${className}` : '';

} else if (URI.isUri(metadata.iconPath)) {
// background-image
template.icon.className = 'uri-icon';
template.icon.style.setProperty('--background-dark', `url("${metadata.iconPath.toString(true)}")`);
template.icon.style.setProperty('--background-light', `url("${metadata.iconPath.toString(true)}")`);

} else if (metadata.iconPath) {
// background-image
template.icon.className = 'uri-icon';
Expand Down

0 comments on commit 3e21159

Please sign in to comment.