mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
scm: deprecate scm.inputBox
This commit is contained in:
@@ -8,6 +8,7 @@ import URI from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, IMainContext } from './extHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -42,12 +43,6 @@ export class ExtHostSCMInputBox {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
private _onDidAccept = new Emitter<string>();
|
||||
|
||||
get onDidAccept(): Event<string> {
|
||||
return this._onDidAccept.event;
|
||||
}
|
||||
|
||||
constructor(private _proxy: MainThreadSCMShape) {
|
||||
// noop
|
||||
}
|
||||
@@ -56,10 +51,6 @@ export class ExtHostSCMInputBox {
|
||||
this.updateValue(value);
|
||||
}
|
||||
|
||||
$onInputBoxAcceptChanges(): void {
|
||||
this._onDidAccept.fire(this._value);
|
||||
}
|
||||
|
||||
private updateValue(value: string): void {
|
||||
this._value = value;
|
||||
this._onDidChange.fire(value);
|
||||
@@ -171,6 +162,9 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
||||
return this._label;
|
||||
}
|
||||
|
||||
private _inputBox: ExtHostSCMInputBox;
|
||||
get inputBox(): ExtHostSCMInputBox { return this._inputBox; }
|
||||
|
||||
private _count: number | undefined = undefined;
|
||||
|
||||
get count(): number | undefined {
|
||||
@@ -238,6 +232,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
||||
private _id: string,
|
||||
private _label: string,
|
||||
) {
|
||||
this._inputBox = new ExtHostSCMInputBox(this._proxy);
|
||||
this._proxy.$registerSourceControl(this._handle, _id, _label);
|
||||
}
|
||||
|
||||
@@ -266,22 +261,16 @@ export class ExtHostSCM {
|
||||
|
||||
private _proxy: MainThreadSCMShape;
|
||||
private _sourceControls: Map<ProviderHandle, ExtHostSourceControl> = new Map<ProviderHandle, ExtHostSourceControl>();
|
||||
private _sourceControlsByExtension: Map<string, ExtHostSourceControl[]> = new Map<string, ExtHostSourceControl[]>();
|
||||
|
||||
private _onDidChangeActiveProvider = new Emitter<vscode.SourceControl>();
|
||||
get onDidChangeActiveProvider(): Event<vscode.SourceControl> { return this._onDidChangeActiveProvider.event; }
|
||||
|
||||
private _activeProvider: vscode.SourceControl | undefined;
|
||||
get activeProvider(): vscode.SourceControl | undefined { return this._activeProvider; }
|
||||
|
||||
private _inputBox: ExtHostSCMInputBox;
|
||||
get inputBox(): ExtHostSCMInputBox { return this._inputBox; }
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext,
|
||||
private _commands: ExtHostCommands
|
||||
) {
|
||||
this._proxy = mainContext.get(MainContext.MainThreadSCM);
|
||||
this._inputBox = new ExtHostSCMInputBox(this._proxy);
|
||||
|
||||
_commands.registerArgumentProcessor({
|
||||
processArgument: arg => {
|
||||
@@ -322,14 +311,27 @@ export class ExtHostSCM {
|
||||
});
|
||||
}
|
||||
|
||||
createSourceControl(id: string, label: string): vscode.SourceControl {
|
||||
createSourceControl(extension: IExtensionDescription, id: string, label: string): vscode.SourceControl {
|
||||
const handle = ExtHostSCM._handlePool++;
|
||||
const sourceControl = new ExtHostSourceControl(this._proxy, this._commands.converter, id, label);
|
||||
this._sourceControls.set(handle, sourceControl);
|
||||
|
||||
const sourceControls = this._sourceControlsByExtension.get(extension.id) || [];
|
||||
sourceControls.push(sourceControl);
|
||||
this._sourceControlsByExtension.set(extension.id, sourceControls);
|
||||
|
||||
return sourceControl;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox {
|
||||
const sourceControls = this._sourceControlsByExtension.get(extension.id);
|
||||
const sourceControl = sourceControls && sourceControls[sourceControls.length - 1];
|
||||
const inputBox = sourceControl && sourceControl.inputBox;
|
||||
|
||||
return inputBox;
|
||||
}
|
||||
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI> {
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
||||
@@ -343,18 +345,14 @@ export class ExtHostSCM {
|
||||
});
|
||||
}
|
||||
|
||||
$onActiveSourceControlChange(handle: number): TPromise<void> {
|
||||
this._activeProvider = this._sourceControls.get(handle);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> {
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
||||
$onInputBoxValueChange(value: string): TPromise<void> {
|
||||
this._inputBox.$onInputBoxValueChange(value);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
if (!sourceControl || !sourceControl.quickDiffProvider) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
$onInputBoxAcceptChanges(): TPromise<void> {
|
||||
this._inputBox.$onInputBoxAcceptChanges();
|
||||
sourceControl.inputBox.$onInputBoxValueChange(value);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user