mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
@@ -14,26 +14,20 @@ import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGr
|
||||
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { Command } from 'vs/editor/common/modes';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { ISplice, ISequence } from 'vs/base/common/sequence';
|
||||
import { ISplice, Sequence } from 'vs/base/common/sequence';
|
||||
|
||||
class MainThreadSCMResourceCollection implements ISequence<ISCMResource> {
|
||||
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
|
||||
readonly elements: ISCMResource[] = [];
|
||||
|
||||
private _onDidSplice = new Emitter<ISplice<ISCMResource>>();
|
||||
readonly onDidSplice = this._onDidSplice.event;
|
||||
|
||||
splice(start: number, deleteCount: number, toInsert: ISCMResource[]) {
|
||||
this.elements.splice(start, deleteCount, ...toInsert);
|
||||
this._onDidSplice.fire({ start, deleteCount, toInsert });
|
||||
}
|
||||
}
|
||||
|
||||
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
|
||||
readonly resources = new MainThreadSCMResourceCollection();
|
||||
get hideWhenEmpty(): boolean { return this.features.hideWhenEmpty; }
|
||||
|
||||
private _onDidChange = new Emitter<void>();
|
||||
get onDidChange(): Event<void> { return this._onDidChange.event; }
|
||||
|
||||
constructor(
|
||||
private sourceControlHandle: number,
|
||||
private handle: number,
|
||||
@@ -50,6 +44,21 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
groupHandle: this.handle
|
||||
};
|
||||
}
|
||||
|
||||
splice(start: number, deleteCount: number, toInsert: ISCMResource[]) {
|
||||
this.elements.splice(start, deleteCount, ...toInsert);
|
||||
this._onDidSplice.fire({ start, deleteCount, toInsert });
|
||||
}
|
||||
|
||||
$updateGroup(features: SCMGroupFeatures): void {
|
||||
this.features = assign(this.features, features);
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
|
||||
$updateGroupLabel(label: string): void {
|
||||
this.label = label;
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class MainThreadSCMResource implements ISCMResource {
|
||||
@@ -84,13 +93,18 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
private _id = `scm${MainThreadSCMProvider.ID_HANDLE++}`;
|
||||
get id(): string { return this._id; }
|
||||
|
||||
private _groups: MainThreadSCMResourceGroup[] = [];
|
||||
readonly groups = new Sequence<MainThreadSCMResourceGroup>();
|
||||
private _groupsByHandle: { [handle: number]: MainThreadSCMResourceGroup; } = Object.create(null);
|
||||
|
||||
get resources(): ISCMResourceGroup[] {
|
||||
return this._groups
|
||||
.filter(g => g.resources.elements.length > 0 || !g.features.hideWhenEmpty);
|
||||
}
|
||||
// get groups(): ISequence<ISCMResourceGroup> {
|
||||
// return {
|
||||
// elements: this._groups,
|
||||
// onDidSplice: this._onDidSplice.event
|
||||
// };
|
||||
|
||||
// // return this._groups
|
||||
// // .filter(g => g.resources.elements.length > 0 || !g.features.hideWhenEmpty);
|
||||
// }
|
||||
|
||||
private _onDidChangeResources = new Emitter<void>();
|
||||
get onDidChangeResources(): Event<void> { return this._onDidChangeResources.event; }
|
||||
@@ -141,8 +155,8 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
id
|
||||
);
|
||||
|
||||
this._groups.push(group);
|
||||
this._groupsByHandle[handle] = group;
|
||||
this.groups.splice(this.groups.elements.length, 0, [group]);
|
||||
}
|
||||
|
||||
$updateGroup(handle: number, features: SCMGroupFeatures): void {
|
||||
@@ -152,8 +166,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
group.features = assign(group.features, features);
|
||||
this._onDidChange.fire();
|
||||
group.$updateGroup(features);
|
||||
}
|
||||
|
||||
$updateGroupLabel(handle: number, label: string): void {
|
||||
@@ -163,8 +176,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
group.label = label;
|
||||
this._onDidChange.fire();
|
||||
group.$updateGroupLabel(label);
|
||||
}
|
||||
|
||||
$spliceGroupResourceStates(splices: SCMRawResourceSplices[]): void {
|
||||
@@ -206,7 +218,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
);
|
||||
});
|
||||
|
||||
group.resources.splice(start, deleteCount, resources);
|
||||
group.splice(start, deleteCount, resources);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +233,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
}
|
||||
|
||||
delete this._groupsByHandle[handle];
|
||||
this._groups.splice(this._groups.indexOf(group), 1);
|
||||
this.groups.splice(this.groups.elements.indexOf(group), 1);
|
||||
}
|
||||
|
||||
getOriginalResource(uri: URI): TPromise<URI> {
|
||||
|
||||
Reference in New Issue
Block a user