🐛 remove the notion of active scm provider

introduces more changes to the SCM api

fixes #23623
fixes #23676
This commit is contained in:
Joao Moreno
2017-03-30 21:10:34 +02:00
parent ce46000fe6
commit a8b2945855
13 changed files with 253 additions and 96 deletions

View File

@@ -253,6 +253,9 @@ export abstract class MainProcessExtensionServiceShape {
export interface SCMProviderFeatures {
hasQuickDiffProvider?: boolean;
count?: number;
commitTemplate?: string;
acceptInputCommand?: modes.Command;
statusBarCommands?: modes.Command[];
}
export interface SCMGroupFeatures {

View File

@@ -192,6 +192,10 @@ export class CommandsConverter {
result.arguments = [id];
}
if (command.tooltip) {
result.tooltip = command.tooltip;
}
return result;
}

View File

@@ -181,6 +181,43 @@ class ExtHostSourceControl implements vscode.SourceControl {
this._proxy.$updateSourceControl(this._handle, { hasQuickDiffProvider: !!quickDiffProvider });
}
private _commitTemplate: string | undefined = undefined;
get commitTemplate(): string | undefined {
return this._commitTemplate;
}
set commitTemplate(commitTemplate: string | undefined) {
this._commitTemplate = commitTemplate;
this._proxy.$updateSourceControl(this._handle, { commitTemplate });
}
private _acceptInputCommand: vscode.Command | undefined = undefined;
get acceptInputCommand(): vscode.Command | undefined {
return this._acceptInputCommand;
}
set acceptInputCommand(acceptInputCommand: vscode.Command | undefined) {
this._acceptInputCommand = acceptInputCommand;
const internal = this._commands.toInternal(acceptInputCommand);
this._proxy.$updateSourceControl(this._handle, { acceptInputCommand: internal });
}
private _statusBarCommands: vscode.Command[] | undefined = undefined;
get statusBarCommands(): vscode.Command[] | undefined {
return this._statusBarCommands;
}
set statusBarCommands(statusBarCommands: vscode.Command[] | undefined) {
this._statusBarCommands = statusBarCommands;
const internal = (statusBarCommands || []).map(c => this._commands.toInternal(c));
this._proxy.$updateSourceControl(this._handle, { statusBarCommands: internal });
}
private _handle: number = ExtHostSourceControl._handlePool++;
constructor(

View File

@@ -78,6 +78,13 @@ class MainThreadSCMProvider implements ISCMProvider {
get label(): string { return this._label; }
get contextKey(): string { return this._id; }
get commitTemplate(): string | undefined { return this.features.commitTemplate; }
get acceptInputCommand(): Command | undefined { return this.features.acceptInputCommand; }
get statusBarCommands(): Command[] | undefined { return this.features.statusBarCommands; }
private _onDidChangeCommitTemplate = new Emitter<string>();
get onDidChangeCommitTemplate(): Event<string> { return this._onDidChangeCommitTemplate.event; }
private _count: number | undefined = undefined;
get count(): number | undefined { return this._count; }
@@ -93,6 +100,10 @@ class MainThreadSCMProvider implements ISCMProvider {
$updateSourceControl(features: SCMProviderFeatures): void {
this.features = assign(this.features, features);
this._onDidChange.fire();
if (typeof features.commitTemplate !== 'undefined') {
this._onDidChangeCommitTemplate.fire(this.commitTemplate);
}
}
$registerGroup(handle: number, id: string, label: string): void {
@@ -194,7 +205,6 @@ export class MainThreadSCM extends MainThreadSCMShape {
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);
}
$registerSourceControl(handle: number, id: string, label: string): void {