mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
💥 scm input onDidAccept
This commit is contained in:
@@ -253,7 +253,6 @@ export abstract class MainProcessExtensionServiceShape {
|
||||
export interface SCMProviderFeatures {
|
||||
label: string;
|
||||
supportsOpen: boolean;
|
||||
supportsAcceptChanges: boolean;
|
||||
supportsOriginalResource: boolean;
|
||||
}
|
||||
|
||||
@@ -419,9 +418,9 @@ export abstract class ExtHostTerminalServiceShape {
|
||||
|
||||
export abstract class ExtHostSCMShape {
|
||||
$open(id: string, uri: string): TPromise<void> { throw ni(); }
|
||||
$acceptChanges(id: string): TPromise<void> { throw ni(); }
|
||||
$getOriginalResource(id: string, uri: URI): TPromise<URI> { throw ni(); }
|
||||
$onInputBoxValueChange(value: string): TPromise<void> { throw ni(); }
|
||||
$onInputBoxAcceptChanges(): TPromise<void> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostTaskShape {
|
||||
|
||||
@@ -49,6 +49,12 @@ class ExtHostSCMInputBox {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
private _onDidAccept = new Emitter<string>();
|
||||
|
||||
get onDidAccept(): Event<string> {
|
||||
return this._onDidAccept.event;
|
||||
}
|
||||
|
||||
constructor(private _proxy: MainThreadSCMShape) {
|
||||
// noop
|
||||
}
|
||||
@@ -57,6 +63,10 @@ class ExtHostSCMInputBox {
|
||||
this.updateValue(value);
|
||||
}
|
||||
|
||||
$onInputBoxAcceptChanges(): void {
|
||||
this._onDidAccept.fire(this._value);
|
||||
}
|
||||
|
||||
private updateValue(value: string): void {
|
||||
this._value = value;
|
||||
this._onDidChange.fire(value);
|
||||
@@ -97,7 +107,6 @@ export class ExtHostSCM {
|
||||
this._proxy.$register(providerId, {
|
||||
label: provider.label,
|
||||
supportsOpen: !!provider.open,
|
||||
supportsAcceptChanges: !!provider.acceptChanges,
|
||||
supportsOriginalResource: !!provider.getOriginalResource
|
||||
});
|
||||
|
||||
@@ -158,16 +167,6 @@ export class ExtHostSCM {
|
||||
return asWinJsPromise(token => provider.open(resource, token));
|
||||
}
|
||||
|
||||
$acceptChanges(providerId: string): TPromise<void> {
|
||||
const provider = this._providers[providerId];
|
||||
|
||||
if (!provider) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return asWinJsPromise(token => provider.acceptChanges(token));
|
||||
}
|
||||
|
||||
$getOriginalResource(id: string, uri: URI): TPromise<URI> {
|
||||
const provider = this._providers[id];
|
||||
|
||||
@@ -182,4 +181,9 @@ export class ExtHostSCM {
|
||||
this._inputBox.$onInputBoxValueChange(value);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
$onInputBoxAcceptChanges(): TPromise<void> {
|
||||
this._inputBox.$onInputBoxAcceptChanges();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,6 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return this.proxy.$open(this.id, resource.uri.toString());
|
||||
}
|
||||
|
||||
acceptChanges(): TPromise<void> {
|
||||
if (!this.features.supportsAcceptChanges) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return this.proxy.$acceptChanges(this.id);
|
||||
}
|
||||
|
||||
getOriginalResource(uri: URI): TPromise<URI> {
|
||||
if (!this.features.supportsOriginalResource) {
|
||||
return TPromise.as(null);
|
||||
@@ -116,7 +108,7 @@ export class MainThreadSCM extends MainThreadSCMShape {
|
||||
|
||||
private proxy: ExtHostSCMShape;
|
||||
private providers: { [id: string]: MainThreadSCMProvider; } = Object.create(null);
|
||||
private inputBoxListener: IDisposable;
|
||||
private inputBoxListeners: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@@ -126,9 +118,8 @@ export class MainThreadSCM extends MainThreadSCMShape {
|
||||
super();
|
||||
this.proxy = threadService.get(ExtHostContext.ExtHostSCM);
|
||||
|
||||
this.inputBoxListener = this.scmService.input.onDidChange(value => {
|
||||
this.proxy.$onInputBoxValueChange(value);
|
||||
});
|
||||
this.scmService.input.onDidChange(this.proxy.$onInputBoxValueChange, this.proxy, this.inputBoxListeners);
|
||||
this.scmService.input.onDidAccept(this.proxy.$onInputBoxAcceptChanges, this.proxy, this.inputBoxListeners);
|
||||
}
|
||||
|
||||
$register(id: string, features: SCMProviderFeatures): void {
|
||||
@@ -165,6 +156,6 @@ export class MainThreadSCM extends MainThreadSCMShape {
|
||||
.forEach(id => this.providers[id].dispose());
|
||||
|
||||
this.providers = Object.create(null);
|
||||
this.inputBoxListener = dispose(this.inputBoxListener);
|
||||
this.inputBoxListeners = dispose(this.inputBoxListeners);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user