scm: bulk resources update

related to #32629
This commit is contained in:
Joao
2017-09-06 10:54:25 +02:00
parent 574660101b
commit bff300a730
4 changed files with 114 additions and 70 deletions

View File

@@ -13,7 +13,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations } from 'vs/workbench/services/scm/common/scm';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResource, SCMGroupFeatures, MainContext, IExtHostContext } from '../node/extHost.protocol';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceGroup, SCMGroupFeatures, MainContext, IExtHostContext } from '../node/extHost.protocol';
import { Command } from 'vs/editor/common/modes';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
@@ -152,36 +152,38 @@ class MainThreadSCMProvider implements ISCMProvider {
this._onDidChange.fire();
}
$updateGroupResourceStates(groupHandle: number, resources: SCMRawResource[]): void {
const group = this._groupsByHandle[groupHandle];
$updateGroupResourceStates(groups: SCMRawResourceGroup[]): void {
for (const [groupHandle, resources] of groups) {
const group = this._groupsByHandle[groupHandle];
if (!group) {
return;
if (!group) {
return;
}
group.resources = resources.map(rawResource => {
const [handle, sourceUri, command, icons, tooltip, strikeThrough, faded] = rawResource;
const icon = icons[0];
const iconDark = icons[1] || icon;
const decorations = {
icon: icon && URI.parse(icon),
iconDark: iconDark && URI.parse(iconDark),
tooltip,
strikeThrough,
faded
};
return new MainThreadSCMResource(
this.handle,
groupHandle,
handle,
URI.parse(sourceUri),
command,
group,
decorations
);
});
}
group.resources = resources.map(rawResource => {
const [handle, sourceUri, command, icons, tooltip, strikeThrough, faded] = rawResource;
const icon = icons[0];
const iconDark = icons[1] || icon;
const decorations = {
icon: icon && URI.parse(icon),
iconDark: iconDark && URI.parse(iconDark),
tooltip,
strikeThrough,
faded
};
return new MainThreadSCMResource(
this.handle,
groupHandle,
handle,
URI.parse(sourceUri),
command,
group,
decorations
);
});
this._onDidChange.fire();
}
@@ -312,7 +314,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
provider.$updateGroupLabel(groupHandle, label);
}
$updateGroupResourceStates(sourceControlHandle: number, groupHandle: number, resources: SCMRawResource[]): void {
$updateResourceStates(sourceControlHandle: number, resources: SCMRawResourceGroup[]): void {
const repository = this._repositories[sourceControlHandle];
if (!repository) {
@@ -320,7 +322,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
}
const provider = repository.provider as MainThreadSCMProvider;
provider.$updateGroupResourceStates(groupHandle, resources);
provider.$updateGroupResourceStates(resources);
}
$unregisterGroup(sourceControlHandle: number, handle: number): void {