提交 32f721f8 编写于 作者: J Joao Moreno

scm: deprecate scm.inputBox

上级 da84e2e4
......@@ -5447,7 +5447,10 @@ declare module 'vscode' {
export namespace scm {
/**
* The [input box](#SourceControlInputBox) in the Source Control viewlet.
* The [input box](#SourceControlInputBox) for the last source control
* created by the extension.
*
* @deprecated Use [SourceControl.inputBox](#SourceControl.inputBox) instead
*/
export const inputBox: SourceControlInputBox;
......
......@@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import URI from 'vs/base/common/uri';
import Event, { Emitter } from 'vs/base/common/event';
import { assign } from 'vs/base/common/objects';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IDisposable, dispose, combinedDisposable } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations } from 'vs/workbench/services/scm/common/scm';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
......@@ -231,9 +231,6 @@ export class MainThreadSCM implements MainThreadSCMShape {
@ICommandService private commandService: ICommandService
) {
this._proxy = extHostContext.get(ExtHostContext.ExtHostSCM);
this.scmService.onDidChangeProvider(this.onDidChangeProvider, this, this._disposables);
this.scmService.input.onDidChange(this._proxy.$onInputBoxValueChange, this._proxy, this._disposables);
}
dispose(): void {
......@@ -251,7 +248,10 @@ export class MainThreadSCM implements MainThreadSCMShape {
$registerSourceControl(handle: number, id: string, label: string): void {
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, this.scmService, this.commandService);
this._sourceControls[handle] = provider;
this._sourceControlDisposables[handle] = this.scmService.registerSCMProvider(provider);
const providerDisposable = this.scmService.registerSCMProvider(provider);
const inputDisposable = this.scmService.input.onDidChange(value => this._proxy.$onInputBoxValueChange(handle, value));
this._sourceControlDisposables[handle] = combinedDisposable([providerDisposable, inputDisposable]);
}
$updateSourceControl(handle: number, features: SCMProviderFeatures): void {
......@@ -331,9 +331,4 @@ export class MainThreadSCM implements MainThreadSCMShape {
$setInputBoxValue(value: string): void {
this.scmService.input.value = value;
}
private onDidChangeProvider(provider: ISCMProvider): void {
const handle = Object.keys(this._sourceControls).filter(handle => this._sourceControls[handle] === provider)[0];
this._proxy.$onActiveSourceControlChange(handle && parseInt(handle));
}
}
......@@ -472,7 +472,7 @@ export function createApiFactory(
// namespace: scm
const scm: typeof vscode.scm = {
get inputBox() {
return extHostSCM.inputBox;
return extHostSCM.getLastInputBox(extension);
},
createSourceControl(id: string, label: string) {
telemetryService.publicLog('registerSCMProvider', {
......@@ -481,7 +481,7 @@ export function createApiFactory(
providerLabel: label
});
return extHostSCM.createSourceControl(id, label);
return extHostSCM.createSourceControl(extension, id, label);
}
};
......
......@@ -508,9 +508,7 @@ export interface ExtHostTerminalServiceShape {
export interface ExtHostSCMShape {
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI>;
$onActiveSourceControlChange(sourceControlHandle: number): TPromise<void>;
$onInputBoxValueChange(value: string): TPromise<void>;
$onInputBoxAcceptChanges(): TPromise<void>;
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void>;
}
export interface ExtHostTaskShape {
......
......@@ -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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册