git status through extension!

This commit is contained in:
Joao Moreno
2016-12-01 10:29:12 +01:00
parent 27793c49e8
commit e0e2be3384
10 changed files with 88 additions and 254 deletions

View File

@@ -6,12 +6,11 @@
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import Event, { Emitter/*, debounceEvent*/ } from 'vs/base/common/event';
// import { index } from 'vs/base/common/arrays';
import Event, { Emitter, debounceEvent } from 'vs/base/common/event';
import { asWinJsPromise } from 'vs/base/common/async';
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
import { Disposable } from 'vs/workbench/api/node/extHostTypes';
import { MainContext, MainThreadSCMShape/*, SCMRawResource*/ } from './extHost.protocol';
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceGroup } from './extHost.protocol';
import * as vscode from 'vscode';
export class ExtHostSCM {
@@ -37,37 +36,26 @@ export class ExtHostSCM {
// TODO@joao: should pluck all the things out of the provider
this._providers[id] = provider;
// const resourceGroupsIds = provider.resourceGroups.map(g => g.id);
this._proxy.$register(id, {
label: provider.label,
commitCommand: provider.commitCommand,
clickCommand: provider.clickCommand,
dragCommand: provider.dragCommand,
supportsOriginalResource: !!provider.getOriginalResource
});
// this._proxy.$register(id, {
// commitCommand: provider.commitCommand,
// clickCommand: provider.clickCommand,
// dragCommand: provider.dragCommand,
// resourceGroups: provider.resourceGroups,
// supportsOriginalResource: !!provider.getOriginalResource
// });
const onDidChange = debounceEvent(provider.onDidChange, (l, e) => e, 200);
const onDidChangeListener = onDidChange(resourceGroups => {
const rawResourceGroups = resourceGroups.map(g => {
const rawResources = g.resources.map(r => [r.uri.toString()] as SCMRawResource);
return [g.id, g.label, rawResources] as SCMRawResourceGroup;
});
// const onDidChange = debounceEvent<vscode.SCMResource[], vscode.SCMResource[]>(provider.onDidChange, (l, e) => e, 200);
// const onDidChangeListener = onDidChange(resources => {
// const resourceGroupsById = index(resourceGroupsIds, id => id, () => [] as SCMRawResource[]);
// resources.forEach(resource => {
// const resourceGroup = resourceGroupsById[resource.resourceGroup];
// if (!resourceGroup) {
// // TODO@Joao: ask Joh: should we warn? should we throw?
// return;
// }
// resourceGroup.push({ uri: resource.uri.toString() });
// });
// const result = resourceGroupsIds.map(id => resourceGroupsById[id]);
// this._proxy.$onChange(id, result);
// });
this._proxy.$onChange(id, rawResourceGroups);
});
return new Disposable(() => {
// onDidChangeListener.dispose();
onDidChangeListener.dispose();
delete this._providers[id];
this._proxy.$unregister(id);
});