From 6c94f0a703b02f8508e692a332ba3c55c1fef20e Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:08:48 +0200 Subject: [PATCH] =?UTF-8?q?SCM=20-=20=F0=9F=92=84=20ActionButton=20API=20c?= =?UTF-8?q?leanup=20(#229943)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/git/src/actionButton.ts | 2 +- src/vs/workbench/api/common/extHost.protocol.ts | 3 +-- src/vs/workbench/api/common/extHostSCM.ts | 10 ++++++---- src/vs/workbench/contrib/scm/browser/scmViewPane.ts | 6 +++--- src/vs/workbench/contrib/scm/common/scm.ts | 3 +-- src/vscode-dts/vscode.proposed.scmActionButton.d.ts | 3 +-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/extensions/git/src/actionButton.ts b/extensions/git/src/actionButton.ts index 494972276ac..2fbdaf4f97e 100644 --- a/extensions/git/src/actionButton.ts +++ b/extensions/git/src/actionButton.ts @@ -211,12 +211,12 @@ export class ActionButton { command: { command: 'git.sync', title: l10n.t('{0} Sync Changes{1}{2}', icon, behind, ahead), + shortTitle: `${icon}${behind}${ahead}`, tooltip: this.state.isSyncInProgress ? l10n.t('Synchronizing Changes...') : this.repository.syncTooltip, arguments: [this.repository.sourceControl], }, - description: `${icon}${behind}${ahead}`, enabled: !this.state.isCheckoutInProgress && !this.state.isSyncInProgress }; } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 4900f545fb4..90b6210401f 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1539,9 +1539,8 @@ export interface SCMProviderFeatures { } export interface SCMActionButtonDto { - command: ICommandDto; + command: ICommandDto & { shortTitle?: string }; secondaryCommands?: ICommandDto[][]; - description?: string; enabled: boolean; } diff --git a/src/vs/workbench/api/common/extHostSCM.ts b/src/vs/workbench/api/common/extHostSCM.ts index 53ddbe4d9db..d03aa03266d 100644 --- a/src/vs/workbench/api/common/extHostSCM.ts +++ b/src/vs/workbench/api/common/extHostSCM.ts @@ -11,7 +11,7 @@ import { debounce } from '../../../base/common/decorators.js'; import { DisposableStore, IDisposable, MutableDisposable } from '../../../base/common/lifecycle.js'; import { asPromise } from '../../../base/common/async.js'; import { ExtHostCommands } from './extHostCommands.js'; -import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto, MainThreadTelemetryShape, SCMGroupFeatures, SCMHistoryItemDto, SCMHistoryItemChangeDto, SCMHistoryItemRefDto } from './extHost.protocol.js'; +import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto, MainThreadTelemetryShape, SCMGroupFeatures, SCMHistoryItemDto, SCMHistoryItemChangeDto, SCMHistoryItemRefDto, SCMActionButtonDto } from './extHost.protocol.js'; import { sortedDiff, equals } from '../../../base/common/arrays.js'; import { comparePaths } from '../../../base/common/comparers.js'; import type * as vscode from 'vscode'; @@ -662,13 +662,15 @@ class ExtHostSourceControl implements vscode.SourceControl { const internal = actionButton !== undefined ? { - command: this._commands.converter.toInternal(actionButton.command, this._actionButtonDisposables.value), + command: { + ...this._commands.converter.toInternal(actionButton.command, this._actionButtonDisposables.value), + shortTitle: actionButton.command.shortTitle + }, secondaryCommands: actionButton.secondaryCommands?.map(commandGroup => { return commandGroup.map(command => this._commands.converter.toInternal(command, this._actionButtonDisposables.value!)); }), - description: actionButton.description, enabled: actionButton.enabled - } : undefined; + } satisfies SCMActionButtonDto : undefined; this.#proxy.$updateSourceControl(this.handle, { actionButton: internal ?? null }); } diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index 7a005631e8d..a5ec31b3ad2 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -2994,13 +2994,13 @@ export class SCMActionButton implements IDisposable { }); } else { // Button - this.button = new Button(this.container, { supportIcons: true, supportShortLabel: !!button.description, title: button.command.tooltip, ...defaultButtonStyles }); + this.button = new Button(this.container, { supportIcons: true, supportShortLabel: !!button.command.shortTitle, title: button.command.tooltip, ...defaultButtonStyles }); } this.button.enabled = button.enabled; this.button.label = button.command.title; - if (this.button instanceof Button && button.description) { - this.button.labelShort = button.description; + if (this.button instanceof Button && button.command.shortTitle) { + this.button.labelShort = button.command.shortTitle; } this.button.onDidClick(async () => await this.executeCommand(button.command.id, ...(button.command.arguments || [])), null, this.disposables.value); diff --git a/src/vs/workbench/contrib/scm/common/scm.ts b/src/vs/workbench/contrib/scm/common/scm.ts index 198caf34a60..1bf6c18dc43 100644 --- a/src/vs/workbench/contrib/scm/common/scm.ts +++ b/src/vs/workbench/contrib/scm/common/scm.ts @@ -116,9 +116,8 @@ export interface ISCMInputChangeEvent { } export interface ISCMActionButtonDescriptor { - command: Command; + command: Command & { shortTitle?: string }; secondaryCommands?: Command[][]; - description?: string; enabled: boolean; } diff --git a/src/vscode-dts/vscode.proposed.scmActionButton.d.ts b/src/vscode-dts/vscode.proposed.scmActionButton.d.ts index b035aaddc8d..96b8b1c0e53 100644 --- a/src/vscode-dts/vscode.proposed.scmActionButton.d.ts +++ b/src/vscode-dts/vscode.proposed.scmActionButton.d.ts @@ -7,9 +7,8 @@ declare module 'vscode' { // https://github.com/microsoft/vscode/issues/133935 export interface SourceControlActionButton { - command: Command; + command: Command & { shortTitle?: string }; secondaryCommands?: Command[][]; - description?: string; enabled: boolean; }