SCMActionButton overflow improvements

This commit is contained in:
Ladislau Szomoru
2022-01-07 22:34:12 +01:00
parent e4f4fab9f0
commit ab914793d5
8 changed files with 89 additions and 35 deletions

View File

@@ -6,7 +6,7 @@
import { URI, UriComponents } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, DisposableStore, combinedDisposable } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, IInputValidation, ISCMViewService, InputValidationType } from 'vs/workbench/contrib/scm/common/scm';
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, IInputValidation, ISCMViewService, InputValidationType, ISCMActionButtonDescriptor } from 'vs/workbench/contrib/scm/common/scm';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, IExtHostContext } from '../common/extHost.protocol';
import { Command } from 'vs/editor/common/languages';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
@@ -120,7 +120,7 @@ class MainThreadSCMProvider implements ISCMProvider {
get commitTemplate(): string { return this.features.commitTemplate || ''; }
get acceptInputCommand(): Command | undefined { return this.features.acceptInputCommand; }
get actionButton(): Command | undefined { return this.features.actionButton ?? undefined; }
get actionButton(): ISCMActionButtonDescriptor | undefined { return this.features.actionButton ?? undefined; }
get statusBarCommands(): Command[] | undefined { return this.features.statusBarCommands; }
get count(): number | undefined { return this.features.count; }

View File

@@ -1085,10 +1085,15 @@ export interface SCMProviderFeatures {
count?: number;
commitTemplate?: string;
acceptInputCommand?: modes.Command;
actionButton?: ICommandDto | null;
actionButton?: SCMActionButtonDto | null;
statusBarCommands?: ICommandDto[];
}
export interface SCMActionButtonDto {
command: ICommandDto;
description?: string;
}
export interface SCMGroupFeatures {
hideWhenEmpty?: boolean;
}

View File

@@ -506,18 +506,22 @@ class ExtHostSourceControl implements vscode.SourceControl {
}
private _actionButtonDisposables = new MutableDisposable<DisposableStore>();
private _actionButton: vscode.Command | undefined;
get actionButton(): vscode.Command | undefined {
private _actionButton: vscode.SourceControlActionButton | undefined;
get actionButton(): vscode.SourceControlActionButton | undefined {
checkProposedApiEnabled(this._extension, 'scmActionButton');
return this._actionButton;
}
set actionButton(actionButton: vscode.Command | undefined) {
set actionButton(actionButton: vscode.SourceControlActionButton | undefined) {
checkProposedApiEnabled(this._extension, 'scmActionButton');
this._actionButtonDisposables.value = new DisposableStore();
this._actionButton = actionButton;
const internal = actionButton !== undefined ? this._commands.converter.toInternal(this._actionButton, this._actionButtonDisposables.value) : undefined;
const internal = actionButton !== undefined ?
{
command: this._commands.converter.toInternal(actionButton.command, this._actionButtonDisposables.value),
description: actionButton.description
} : undefined;
this.#proxy.$updateSourceControl(this.handle, { actionButton: internal ?? null });
}