Skip to content

Commit

Permalink
Add full support: SourceControlResource
Browse files Browse the repository at this point in the history
ThemableDecorations.iconPath

The SourceControlResourceThemableDecorations.iconPath now accept
ThemeIcons (similarly as per VS Code API).
  • Loading branch information
Estelle Foisy committed Dec 14, 2022
1 parent 6184572 commit f32537d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/plugin-ext/src/main/browser/scm-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { URI as vscodeURI } from '@theia/core/shared/vscode-uri';
import { Splice } from '../../common/arrays';
import { UriComponents } from '../../common/uri-components';
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';

export class PluginScmResourceGroup implements ScmResourceGroup {

Expand Down Expand Up @@ -222,13 +223,14 @@ export class PluginScmProvider implements ScmProvider {
const { start, deleteCount, rawResources } = groupSlice;
const resources = rawResources.map(rawResource => {
const { handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue, command } = rawResource;
const icon = icons[0];
const iconDark = icons[1] || icon;
const [light, dark] = icons;
const icon = ThemeIcon.isThemeIcon(light) ? light : vscodeURI.revive(light);
const iconDark = (ThemeIcon.isThemeIcon(dark) ? dark : vscodeURI.revive(dark)) || icon;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const colorVariable = (rawResource as any).colorId && this.colors.toCssVariableName((rawResource as any).colorId);
const decorations = {
icon: icon ? vscodeURI.revive(icon) : undefined,
iconDark: iconDark ? vscodeURI.revive(iconDark) : undefined,
icon: icon,
iconDark: iconDark,
tooltip,
strikeThrough,
// TODO remove the letter and colorId fields when the FileDecorationProvider is applied, see https://github.com/eclipse-theia/theia/pull/8911
Expand Down
6 changes: 6 additions & 0 deletions packages/scm/src/browser/scm-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import { Disposable, Event } from '@theia/core/lib/common';
import URI from '@theia/core/lib/common/uri';
// eslint-disable-next-line import/no-extraneous-dependencies
import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';

export interface ScmProvider extends Disposable {
readonly id: string;
Expand Down Expand Up @@ -58,10 +60,14 @@ export interface ScmResource {
}

export interface ScmResourceDecorations {
icon?: URI | ThemeIcon;
iconDark?: URI | ThemeIcon;
tooltip?: string;
source?: string;
letter?: string;
color?: string;
strikeThrough?: boolean;
faded?: boolean;
}

export interface ScmCommand {
Expand Down

0 comments on commit f32537d

Please sign in to comment.