mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
scm: hide input box model from extension host
This commit is contained in:
@@ -424,6 +424,11 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
|
||||
return extHostSCM.onDidChangeActiveProvider;
|
||||
}
|
||||
|
||||
@proposed(extension)
|
||||
get inputBox() {
|
||||
return extHostSCM.inputBox;
|
||||
}
|
||||
|
||||
@proposed(extension)
|
||||
getResourceFromURI(uri) {
|
||||
return extHostSCM.getResourceFromURI(uri);
|
||||
|
||||
@@ -259,6 +259,7 @@ export abstract class MainThreadSCMShape {
|
||||
$register(id: string, features: SCMProviderFeatures): void { throw ni(); }
|
||||
$unregister(id: string): void { throw ni(); }
|
||||
$onChange(id: string, resources: SCMRawResourceGroup[], count: number | undefined): void { throw ni(); }
|
||||
$setInputBoxValue(value: string): void { throw ni(); }
|
||||
}
|
||||
|
||||
// -- extension host
|
||||
@@ -394,6 +395,7 @@ export abstract class ExtHostSCMShape {
|
||||
$open(id: string, resourceGroupId: string, uri: string): TPromise<void> { throw ni(); }
|
||||
$drag(id: string, fromResourceGroupId: string, fromUri: string, toResourceGroupId: string): TPromise<void> { throw ni(); }
|
||||
$getOriginalResource(id: string, uri: URI): TPromise<URI> { throw ni(); }
|
||||
$onInputBoxValueChange(value: string): TPromise<void> { throw ni(); }
|
||||
}
|
||||
|
||||
// --- proxy identifiers
|
||||
|
||||
@@ -33,6 +33,39 @@ export interface Cache {
|
||||
};
|
||||
}
|
||||
|
||||
class ExtHostSCMInputBox {
|
||||
|
||||
private _value: string = '';
|
||||
|
||||
get value(): string {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(value: string) {
|
||||
this._proxy.$setInputBoxValue(value);
|
||||
this.updateValue(value);
|
||||
}
|
||||
|
||||
private _onDidChange = new Emitter<string>();
|
||||
|
||||
get onDidChange(): Event<string> {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
constructor(private _proxy: MainThreadSCMShape) {
|
||||
// noop
|
||||
}
|
||||
|
||||
$onInputBoxValueChange(value: string): void {
|
||||
this.updateValue(value);
|
||||
}
|
||||
|
||||
private updateValue(value: string): void {
|
||||
this._value = value;
|
||||
this._onDidChange.fire(value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostSCM {
|
||||
|
||||
private _proxy: MainThreadSCMShape;
|
||||
@@ -44,10 +77,14 @@ export class ExtHostSCM {
|
||||
private _activeProvider: vscode.SCMProvider;
|
||||
get activeProvider(): vscode.SCMProvider | undefined { return this._activeProvider; }
|
||||
|
||||
private _inputBox: ExtHostSCMInputBox;
|
||||
get inputBox(): vscode.SCMInputBox { return this._inputBox; }
|
||||
|
||||
private cache: Cache = Object.create(null);
|
||||
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadSCM);
|
||||
this._inputBox = new ExtHostSCMInputBox(this._proxy);
|
||||
}
|
||||
|
||||
getResourceFromURI(uri: vscode.Uri): vscode.SCMResource | vscode.SCMResourceGroup | undefined {
|
||||
@@ -209,4 +246,9 @@ export class ExtHostSCM {
|
||||
|
||||
return asWinJsPromise(token => provider.getOriginalResource(uri, token));
|
||||
}
|
||||
|
||||
$onInputBoxValueChange(value: string): TPromise<void> {
|
||||
this._inputBox.$onInputBoxValueChange(value);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,19 @@ export class MainThreadSCM extends MainThreadSCMShape {
|
||||
|
||||
private proxy: ExtHostSCMShape;
|
||||
private providers: { [id: string]: MainThreadSCMProvider; } = Object.create(null);
|
||||
private inputBoxListener: IDisposable;
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@ISCMService private scmService: ISCMService
|
||||
) {
|
||||
super();
|
||||
this.proxy = threadService.get(ExtHostContext.ExtHostSCM);
|
||||
|
||||
this.inputBoxListener = this.scmService.inputBoxModel.onDidChangeContent(e => {
|
||||
this.proxy.$onInputBoxValueChange(this.scmService.inputBoxModel.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
$register(id: string, features: SCMProviderFeatures): void {
|
||||
@@ -144,10 +150,15 @@ export class MainThreadSCM extends MainThreadSCMShape {
|
||||
provider.$onChange(rawResourceGroups, count);
|
||||
}
|
||||
|
||||
$setInputBoxValue(value: string): void {
|
||||
this.scmService.inputBoxModel.setValue(value);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
Object.keys(this.providers)
|
||||
.forEach(id => this.providers[id].dispose());
|
||||
|
||||
this.providers = Object.create(null);
|
||||
this.inputBoxListener = dispose(this.inputBoxListener);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user