🐛 cant commit no more!

fixes #23384
This commit is contained in:
Joao Moreno
2017-03-28 12:36:00 +02:00
parent 54d9cbcd69
commit 0b19861f31
3 changed files with 25 additions and 7 deletions

View File

@@ -420,6 +420,7 @@ export abstract class ExtHostTerminalServiceShape {
export abstract class ExtHostSCMShape {
$open(handle: number, uri: string): TPromise<void> { throw ni(); }
$getOriginalResource(handle: number, uri: URI): TPromise<URI> { throw ni(); }
$onActiveProviderChange(handle: number): TPromise<void> { throw ni(); }
$onInputBoxValueChange(value: string): TPromise<void> { throw ni(); }
$onInputBoxAcceptChanges(): TPromise<void> { throw ni(); }
}

View File

@@ -80,7 +80,7 @@ export class ExtHostSCM {
private _onDidChangeActiveProvider = new Emitter<vscode.SCMProvider>();
get onDidChangeActiveProvider(): Event<vscode.SCMProvider> { return this._onDidChangeActiveProvider.event; }
private _activeProvider: vscode.SCMProvider;
private _activeProvider: vscode.SCMProvider | undefined;
get activeProvider(): vscode.SCMProvider | undefined { return this._activeProvider; }
private _inputBox: ExtHostSCMInputBox;
@@ -178,6 +178,11 @@ export class ExtHostSCM {
return asWinJsPromise(token => provider.provideOriginalResource(uri, token));
}
$onActiveProviderChange(handle: number): TPromise<void> {
this._activeProvider = this._providers.get(handle);
return TPromise.as(null);
}
$onInputBoxValueChange(value: string): TPromise<void> {
this._inputBox.$onInputBoxValueChange(value);
return TPromise.as(null);

View File

@@ -43,7 +43,6 @@ class MainThreadSCMProvider implements ISCMProvider {
@ICommandService private commandService: ICommandService
) {
scmService.onDidChangeProvider(this.onDidChangeProvider, this, this.disposables);
this.disposables.push(scmService.registerSCMProvider(this));
}
open(resource: ISCMResource): void {
@@ -111,7 +110,9 @@ export class MainThreadSCM extends MainThreadSCMShape {
private proxy: ExtHostSCMShape;
private providers: { [handle: number]: MainThreadSCMProvider; } = Object.create(null);
private inputBoxListeners: IDisposable[] = [];
private providerDisposables: { [handle: number]: IDisposable; } = Object.create(null);
private disposables: IDisposable[] = [];
constructor(
@IThreadService threadService: IThreadService,
@@ -121,12 +122,15 @@ export class MainThreadSCM extends MainThreadSCMShape {
super();
this.proxy = threadService.get(ExtHostContext.ExtHostSCM);
this.scmService.input.onDidChange(this.proxy.$onInputBoxValueChange, this.proxy, this.inputBoxListeners);
this.scmService.input.onDidAccept(this.proxy.$onInputBoxAcceptChanges, this.proxy, this.inputBoxListeners);
this.scmService.onDidChangeProvider(this.onDidChangeProvider, this, this.disposables);
this.scmService.input.onDidChange(this.proxy.$onInputBoxValueChange, this.proxy, this.disposables);
this.scmService.input.onDidAccept(this.proxy.$onInputBoxAcceptChanges, this.proxy, this.disposables);
}
$register(handle: number, features: SCMProviderFeatures): void {
this.providers[handle] = this.instantiationService.createInstance(MainThreadSCMProvider, handle, this.proxy, features);
const provider = this.instantiationService.createInstance(MainThreadSCMProvider, handle, this.proxy, features);
this.providers[handle] = provider;
this.providerDisposables[handle] = this.scmService.registerSCMProvider(provider);
}
$unregister(handle: number): void {
@@ -136,6 +140,9 @@ export class MainThreadSCM extends MainThreadSCMShape {
return;
}
this.providerDisposables[handle].dispose();
delete this.providerDisposables[handle];
provider.dispose();
delete this.providers[handle];
}
@@ -154,11 +161,16 @@ export class MainThreadSCM extends MainThreadSCMShape {
this.scmService.input.value = value;
}
private onDidChangeProvider(provider: ISCMProvider): void {
const handle = Object.keys(this.providers).filter(handle => this.providers[handle] === provider)[0];
this.proxy.$onActiveProviderChange(handle && parseInt(handle));
}
dispose(): void {
Object.keys(this.providers)
.forEach(id => this.providers[id].dispose());
this.providers = Object.create(null);
this.inputBoxListeners = dispose(this.inputBoxListeners);
this.disposables = dispose(this.disposables);
}
}