Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eclipse-theia/theia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7628706dc75630bea48ca145c936a29e80961495
Choose a base ref
..
head repository: eclipse-theia/theia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d16c3f170b6b0fdf6b679182f700b244b0b7f264
Choose a head ref
Showing with 16 additions and 3 deletions.
  1. +12 −2 packages/plugin-ext/src/main/browser/scm-main.ts
  2. +4 −1 packages/plugin-ext/src/plugin/scm.ts
14 changes: 12 additions & 2 deletions packages/plugin-ext/src/main/browser/scm-main.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ import URI from '@theia/core/lib/common/uri';
import { URI as vscodeURI } from 'vscode-uri';
import { Splice } from '../../common/arrays';
import { UriComponents } from '../../common/uri-components';
import { ColorRegistry } from '@theia/core/lib/browser/color-registry';

export class PluginScmResourceGroup implements ScmResourceGroup {

@@ -138,6 +139,7 @@ export class PluginScmProvider implements ScmProvider {

constructor(
private readonly proxy: ScmExt,
private readonly colors: ColorRegistry,
private readonly _handle: number,
private readonly _contextValue: string,
private readonly _label: string,
@@ -215,13 +217,19 @@ export class PluginScmProvider implements ScmProvider {
const { handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue, command } = rawResource;
const icon = icons[0];
const iconDark = icons[1] || 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,
tooltip,
strikeThrough,
// TODO remove the letter and colorId fields when the FileDecorationProvider is applied, see https://github.com/eclipse-theia/theia/pull/8911
// eslint-disable-next-line @typescript-eslint/no-explicit-any
letter: (rawResource as any).letter || '',
color: colorVariable && `var(${colorVariable})`,
faded
};
} as ScmResourceDecorations;

return new PluginScmResource(
this.proxy,
@@ -264,10 +272,12 @@ export class ScmMainImpl implements ScmMain {
private repositories = new Map<number, ScmRepository>();
private repositoryDisposables = new Map<number, DisposableCollection>();
private readonly disposables = new DisposableCollection();
private readonly colors: ColorRegistry;

constructor( rpc: RPCProtocol, container: interfaces.Container) {
this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.SCM_EXT);
this.scmService = container.get(ScmService);
this.colors = container.get(ColorRegistry);
}

dispose(): void {
@@ -281,7 +291,7 @@ export class ScmMainImpl implements ScmMain {
}

async $registerSourceControl(handle: number, id: string, label: string, rootUri: UriComponents | undefined): Promise<void> {
const provider = new PluginScmProvider(this.proxy, handle, id, label, rootUri ? vscodeURI.revive(rootUri) : undefined);
const provider = new PluginScmProvider(this.proxy, this.colors, handle, id, label, rootUri ? vscodeURI.revive(rootUri) : undefined);
const repository = this.scmService.registerScmProvider(provider, {
input: {
validator: async value => {
5 changes: 4 additions & 1 deletion packages/plugin-ext/src/plugin/scm.ts
Original file line number Diff line number Diff line change
@@ -450,7 +450,10 @@ class SsmResourceGroupImpl implements theia.SourceControlResourceGroup {
const faded = r.decorations && !!r.decorations.faded;
const contextValue = r.contextValue || '';

const rawResource = { handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue, command } as ScmRawResource;
// TODO remove the letter and colorId fields when the FileDecorationProvider is applied, see https://github.com/eclipse-theia/theia/pull/8911
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const rawResource = { handle, sourceUri, letter: (r as any).letter, colorId: (r as any).color.id, icons,
tooltip, strikeThrough, faded, contextValue, command } as ScmRawResource;

return { rawResource, handle };
});