SCM - delete scmInputBoxActionButton proposal (#200012)

This commit is contained in:
Ladislau Szomoru 2023-12-05 10:52:01 +01:00 committed by GitHub
parent c93a2d9e39
commit 1466cbfcdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 7 additions and 447 deletions

View file

@ -24,7 +24,6 @@
"tabInputTextMerge",
"timeline",
"contribMergeEditorMenus",
"scmInputBoxActionButton",
"contribSourceControlInputBoxMenu"
],
"categories": [

View file

@ -5,7 +5,7 @@
import { Model } from '../model';
import { Repository as BaseRepository, Resource } from '../repository';
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions, CommitMessageProvider } from './git';
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions } from './git';
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands, CancellationToken } from 'vscode';
import { combinedDisposable, mapEvent } from '../util';
import { toGitUri } from '../uri';
@ -345,13 +345,6 @@ export class ApiImpl implements API {
return this._model.registerBranchProtectionProvider(root, provider);
}
/**
* @deprecated See https://github.com/microsoft/vscode/issues/195474
*/
registerCommitMessageProvider(provider: CommitMessageProvider): Disposable {
return this._model.registerCommitMessageProvider(provider);
}
constructor(private _model: Model) { }
}

View file

@ -312,12 +312,6 @@ export interface BranchProtectionProvider {
provideBranchProtection(): BranchProtection[];
}
export interface CommitMessageProvider {
readonly title: string;
readonly icon?: Uri | { light: Uri, dark: Uri } | ThemeIcon;
provideCommitMessage(repository: Repository, changes: string[], cancellationToken?: CancellationToken): Promise<string | undefined>;
}
export type APIState = 'uninitialized' | 'initialized';
export interface PublishEvent {
@ -345,7 +339,6 @@ export interface API {
registerPostCommitCommandsProvider(provider: PostCommitCommandsProvider): Disposable;
registerPushErrorHandler(handler: PushErrorHandler): Disposable;
registerBranchProtectionProvider(root: Uri, provider: BranchProtectionProvider): Disposable;
registerCommitMessageProvider(provider: CommitMessageProvider): Disposable;
}
export interface GitExtension {

View file

@ -3631,26 +3631,6 @@ export class CommandCenter {
}
}
@command('git.generateCommitMessage', { repository: true })
async generateCommitMessage(repository: Repository): Promise<void> {
if (!repository || !this.model.commitMessageProvider) {
return;
}
await window.withProgress({ location: ProgressLocation.SourceControl }, async () => {
await repository.generateCommitMessage();
});
}
@command('git.generateCommitMessageCancel', { repository: true })
generateCommitMessageCancel(repository: Repository): void {
if (!repository || !this.model.commitMessageProvider) {
return;
}
repository.generateCommitMessageCancel();
}
@command('git.viewChanges', { repository: true })
viewChanges(repository: Repository): void {
this._viewChanges('Git: Changes', repository.workingTreeGroup.resourceStates);

View file

@ -1,188 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, Disposable, Event, EventEmitter, Uri, workspace, ThemeIcon, l10n, SourceControlInputBoxActionButton } from 'vscode';
import { CommitMessageProvider, Status, Repository as ApiRepository } from './api/git';
import { Repository } from './repository';
import { dispose } from './util';
export interface ICommitMessageProviderRegistry {
readonly onDidChangeCommitMessageProvider: Event<void>;
commitMessageProvider: CommitMessageProvider | undefined;
registerCommitMessageProvider(provider: CommitMessageProvider): Disposable;
}
export class TestCommitMessageProvider implements CommitMessageProvider {
readonly icon = new ThemeIcon('rocket');
readonly title = 'Generate Commit Message (Test)';
private readonly _changesMap = new Map<string, [string[], number]>();
async provideCommitMessage(repository: ApiRepository, changes: string[], token: CancellationToken): Promise<string | undefined> {
console.log('Repository: ', repository.rootUri.fsPath);
if (token.isCancellationRequested) {
return undefined;
}
return new Promise(resolve => {
token.onCancellationRequested(() => resolve(undefined));
setTimeout(() => {
const attemptCount = this.getAttemptCount(repository, changes);
this._changesMap.set(repository.rootUri.fsPath, [changes, attemptCount]);
resolve(`Test commit message (Attempt No. ${attemptCount})`);
}, 5000);
});
}
private getAttemptCount(repository: ApiRepository, changes: string[]): number {
const [previousChanges, previousCount] = this._changesMap.get(repository.rootUri.fsPath) ?? [[], 1];
if (previousChanges.length !== changes.length) {
return 1;
}
for (let index = 0; index < changes.length; index++) {
if (previousChanges[index] !== changes[index]) {
return 1;
}
}
return previousCount + 1;
}
}
interface ActionButtonState {
readonly isGenerating: boolean;
readonly enabled: boolean;
}
export class GenerateCommitMessageActionButton {
private _onDidChange = new EventEmitter<void>();
get onDidChange(): Event<void> { return this._onDidChange.event; }
private _state: ActionButtonState;
get state() { return this._state; }
set state(state: ActionButtonState) {
if (this._state.enabled === state.enabled &&
this._state.isGenerating === state.isGenerating) {
return;
}
this._state = state;
this._onDidChange.fire();
}
get button(): SourceControlInputBoxActionButton | undefined {
if (this.commitMessageProviderRegistry.commitMessageProvider === undefined) {
return undefined;
}
return this.state.isGenerating ?
{
icon: new ThemeIcon('debug-stop'),
command: {
title: l10n.t('Cancel'),
command: 'git.generateCommitMessageCancel',
arguments: [this.repository.sourceControl]
},
enabled: this.state.enabled,
} :
{
icon: this.commitMessageProviderRegistry.commitMessageProvider.icon ?? new ThemeIcon('sparkle'),
command: {
title: this.commitMessageProviderRegistry.commitMessageProvider.title,
command: 'git.generateCommitMessage',
arguments: [this.repository.sourceControl]
},
enabled: this.state.enabled
};
}
private disposables: Disposable[] = [];
constructor(
private readonly repository: Repository,
private readonly commitMessageProviderRegistry: ICommitMessageProviderRegistry
) {
this._state = {
enabled: false,
isGenerating: false
};
const root = Uri.file(repository.root);
this.disposables.push(workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('git.enableSmartCommit', root) ||
e.affectsConfiguration('git.smartCommitChanges', root) ||
e.affectsConfiguration('git.suggestSmartCommit', root)) {
this.onDidChangeSmartCommitSettings();
}
}));
repository.onDidRunGitStatus(this.onDidRunGitStatus, this, this.disposables);
repository.onDidStartCommitMessageGeneration(this.onDidStartCommitMessageGeneration, this, this.disposables);
repository.onDidEndCommitMessageGeneration(this.onDidEndCommitMessageGeneration, this, this.disposables);
commitMessageProviderRegistry.onDidChangeCommitMessageProvider(this.onDidChangeCommitMessageProvider, this, this.disposables);
}
private onDidChangeCommitMessageProvider(): void {
this._onDidChange.fire();
}
private onDidStartCommitMessageGeneration(): void {
this.state = { ...this.state, isGenerating: true };
}
private onDidEndCommitMessageGeneration(): void {
this.state = { ...this.state, isGenerating: false };
}
private onDidChangeSmartCommitSettings(): void {
this.state = {
...this.state,
enabled: this.repositoryHasChangesToCommit()
};
}
private onDidRunGitStatus(): void {
this.state = {
...this.state,
enabled: this.repositoryHasChangesToCommit()
};
}
private repositoryHasChangesToCommit(): boolean {
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
const enableSmartCommit = config.get<boolean>('enableSmartCommit') === true;
const suggestSmartCommit = config.get<boolean>('suggestSmartCommit') === true;
const smartCommitChanges = config.get<'all' | 'tracked'>('smartCommitChanges', 'all');
const resources = [...this.repository.indexGroup.resourceStates];
if (
// Smart commit enabled (all)
(enableSmartCommit && smartCommitChanges === 'all') ||
// Smart commit disabled, smart suggestion enabled
(!enableSmartCommit && suggestSmartCommit)
) {
resources.push(...this.repository.workingTreeGroup.resourceStates);
}
// Smart commit enabled (tracked only)
if (enableSmartCommit && smartCommitChanges === 'tracked') {
resources.push(...this.repository.workingTreeGroup.resourceStates.filter(r => r.type !== Status.UNTRACKED));
}
return resources.length !== 0;
}
dispose(): void {
this.disposables = dispose(this.disposables);
}
}

View file

@ -12,14 +12,13 @@ import { Git } from './git';
import * as path from 'path';
import * as fs from 'fs';
import { fromGitUri } from './uri';
import { APIState as State, CredentialsProvider, PushErrorHandler, PublishEvent, RemoteSourcePublisher, PostCommitCommandsProvider, BranchProtectionProvider, CommitMessageProvider } from './api/git';
import { APIState as State, CredentialsProvider, PushErrorHandler, PublishEvent, RemoteSourcePublisher, PostCommitCommandsProvider, BranchProtectionProvider } from './api/git';
import { Askpass } from './askpass';
import { IPushErrorHandlerRegistry } from './pushError';
import { ApiRepository } from './api/api1';
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
import { IPostCommitCommandsProviderRegistry } from './postCommitCommands';
import { IBranchProtectionProviderRegistry } from './branchProtection';
import { ICommitMessageProviderRegistry } from './commitMessageProvider';
class RepositoryPick implements QuickPickItem {
@memoize get label(): string {
@ -171,7 +170,7 @@ class UnsafeRepositoriesManager {
}
}
export class Model implements IRepositoryResolver, IBranchProtectionProviderRegistry, ICommitMessageProviderRegistry, IRemoteSourcePublisherRegistry, IPostCommitCommandsProviderRegistry, IPushErrorHandlerRegistry {
export class Model implements IRepositoryResolver, IBranchProtectionProviderRegistry, IRemoteSourcePublisherRegistry, IPostCommitCommandsProviderRegistry, IPushErrorHandlerRegistry {
private _onDidOpenRepository = new EventEmitter<Repository>();
readonly onDidOpenRepository: Event<Repository> = this._onDidOpenRepository.event;
@ -238,14 +237,6 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
private pushErrorHandlers = new Set<PushErrorHandler>();
private _commitMessageProvider: CommitMessageProvider | undefined;
get commitMessageProvider(): CommitMessageProvider | undefined {
return this._commitMessageProvider;
}
private _onDidChangeCommitMessageProvider = new EventEmitter<void>();
readonly onDidChangeCommitMessageProvider = this._onDidChangeCommitMessageProvider.event;
private _unsafeRepositoriesManager: UnsafeRepositoriesManager;
get unsafeRepositories(): string[] {
return this._unsafeRepositoriesManager.repositories;
@ -587,7 +578,7 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
// Open repository
const [dotGit, repositoryRootRealPath] = await Promise.all([this.git.getRepositoryDotGit(repositoryRoot), this.getRepositoryRootRealPath(repositoryRoot)]);
const repository = new Repository(this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger), this, this, this, this, this, this, this.globalState, this.logger, this.telemetryReporter);
const repository = new Repository(this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger), this, this, this, this, this, this.globalState, this.logger, this.telemetryReporter);
this.open(repository);
this._closedRepositoriesManager.deleteRepository(repository.root);
@ -948,16 +939,6 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
return toDisposable(() => this.pushErrorHandlers.delete(handler));
}
registerCommitMessageProvider(provider: CommitMessageProvider): Disposable {
this._commitMessageProvider = provider;
this._onDidChangeCommitMessageProvider.fire();
return toDisposable(() => {
this._commitMessageProvider = undefined;
this._onDidChangeCommitMessageProvider.fire();
});
}
getPushErrorHandlers(): PushErrorHandler[] {
return [...this.pushErrorHandlers];
}

View file

@ -24,7 +24,6 @@ import { IPostCommitCommandsProviderRegistry, CommitCommandsCenter } from './pos
import { Operation, OperationKind, OperationManager, OperationResult } from './operation';
import { GitBranchProtectionProvider, IBranchProtectionProviderRegistry } from './branchProtection';
import { GitHistoryProvider } from './historyProvider';
import { GenerateCommitMessageActionButton, ICommitMessageProviderRegistry } from './commitMessageProvider';
const timeout = (millis: number) => new Promise(c => setTimeout(c, millis));
@ -34,47 +33,6 @@ function getIconUri(iconName: string, theme: string): Uri {
return Uri.file(path.join(iconsRootPath, theme, `${iconName}.svg`));
}
function wrapCommitMessage(message: string, subjectLineLength: number, bodyLineLength: number): string {
const messageLinesWrapped: string[] = [];
const messageLines = message.split(/\r?\n/g);
for (let index = 0; index < messageLines.length; index++) {
const messageLine = messageLines[index];
const threshold = index === 0 ? subjectLineLength : bodyLineLength;
if (messageLine.length <= threshold) {
messageLinesWrapped.push(messageLine);
continue;
}
let position = 0;
const lineSegments: string[] = [];
while (messageLine.length - position > threshold) {
const lastSpaceBeforeThreshold = messageLine.lastIndexOf(' ', position + threshold);
if (lastSpaceBeforeThreshold !== -1 && lastSpaceBeforeThreshold > position) {
lineSegments.push(...[messageLine.substring(position, lastSpaceBeforeThreshold), '\n']);
position = lastSpaceBeforeThreshold + 1;
} else {
// Find first space after threshold
const firstSpaceAfterThreshold = messageLine.indexOf(' ', position);
if (firstSpaceAfterThreshold !== -1) {
lineSegments.push(...[messageLine.substring(position, firstSpaceAfterThreshold), '\n']);
position = firstSpaceAfterThreshold + 1;
} else {
lineSegments.push(messageLine.substring(position));
position = messageLine.length;
}
}
}
if (position < messageLine.length) {
lineSegments.push(messageLine.substring(position));
}
messageLinesWrapped.push(lineSegments.join(''));
}
return messageLinesWrapped.join('\n');
}
export const enum RepositoryState {
Idle,
Disposed
@ -845,7 +803,6 @@ export class Repository implements Disposable {
private commitCommandCenter: CommitCommandsCenter;
private resourceCommandResolver = new ResourceCommandResolver(this);
private updateModelStateCancellationTokenSource: CancellationTokenSource | undefined;
private generateCommitMessageCancellationTokenSource: CancellationTokenSource | undefined;
private disposables: Disposable[] = [];
constructor(
@ -855,7 +812,6 @@ export class Repository implements Disposable {
remoteSourcePublisherRegistry: IRemoteSourcePublisherRegistry,
postCommitCommandsProviderRegistry: IPostCommitCommandsProviderRegistry,
private readonly branchProtectionProviderRegistry: IBranchProtectionProviderRegistry,
private readonly commitMessageProviderRegistry: ICommitMessageProviderRegistry,
globalState: Memento,
private readonly logger: LogOutputChannel,
private telemetryReporter: TelemetryReporter
@ -901,11 +857,6 @@ export class Repository implements Disposable {
this._sourceControl.acceptInputCommand = { command: 'git.commit', title: l10n.t('Commit'), arguments: [this._sourceControl] };
this._sourceControl.inputBox.validateInput = this.validateInput.bind(this);
const inputActionButton = new GenerateCommitMessageActionButton(this, commitMessageProviderRegistry);
this.disposables.push(inputActionButton);
inputActionButton.onDidChange(() => this._sourceControl.inputBox.actionButton = inputActionButton.button);
this._sourceControl.inputBox.actionButton = inputActionButton.button;
this.disposables.push(this._sourceControl);
this.updateInputBoxPlaceholder();
@ -2086,58 +2037,6 @@ export class Repository implements Disposable {
});
}
async generateCommitMessage(): Promise<void> {
if (!this.commitMessageProviderRegistry.commitMessageProvider) {
return;
}
this._onDidStartCommitMessageGeneration.fire();
this.generateCommitMessageCancellationTokenSource?.cancel();
this.generateCommitMessageCancellationTokenSource = new CancellationTokenSource();
try {
const diff: string[] = [];
if (this.indexGroup.resourceStates.length !== 0) {
for (const file of this.indexGroup.resourceStates.map(r => r.resourceUri.fsPath)) {
diff.push(await this.diffIndexWithHEAD(file));
}
} else {
for (const file of this.workingTreeGroup.resourceStates.map(r => r.resourceUri.fsPath)) {
diff.push(await this.diffWithHEAD(file));
}
}
if (diff.length === 0) {
return;
}
const token = this.generateCommitMessageCancellationTokenSource.token;
const provider = this.commitMessageProviderRegistry.commitMessageProvider;
const commitMessage = await provider.provideCommitMessage(new ApiRepository(this), diff, token);
if (commitMessage) {
const config = workspace.getConfiguration('git');
const subjectLineLength = config.get<number | null>('inputValidationSubjectLength', null);
const bodyLineLength = config.get<number>('inputValidationLength', 50);
this.inputBox.value = wrapCommitMessage(commitMessage, subjectLineLength ?? bodyLineLength, bodyLineLength);
}
}
catch (err) {
this.logger.error(err);
}
finally {
this._onDidEndCommitMessageGeneration.fire();
}
}
generateCommitMessageCancel(): void {
this.generateCommitMessageCancellationTokenSource?.cancel();
this.generateCommitMessageCancellationTokenSource?.dispose();
this.generateCommitMessageCancellationTokenSource = undefined;
this._onDidEndCommitMessageGeneration.fire();
}
// Parses output of `git check-ignore -v -z` and returns only those paths
// that are actually ignored by git.
// Matches to a negative pattern (starting with '!') are filtered out.

View file

@ -13,7 +13,6 @@
"../../src/vscode-dts/vscode.proposed.diffCommand.d.ts",
"../../src/vscode-dts/vscode.proposed.scmActionButton.d.ts",
"../../src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts",
"../../src/vscode-dts/vscode.proposed.scmInputBoxActionButton.d.ts",
"../../src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts",
"../../src/vscode-dts/vscode.proposed.scmValidation.d.ts",
"../../src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts",

View file

@ -7,7 +7,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, DisposableStore, combinedDisposable, dispose } from 'vs/base/common/lifecycle';
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, SCMHistoryItemGroupDto, SCMInputActionButtonDto } from '../common/extHost.protocol';
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, SCMHistoryItemGroupDto } from '../common/extHost.protocol';
import { Command } from 'vs/editor/common/languages';
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { CancellationToken } from 'vs/base/common/cancellation';
@ -22,19 +22,6 @@ import { Codicon } from 'vs/base/common/codicons';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { basename } from 'vs/base/common/resources';
function getSCMInputBoxActionButtonIcon(actionButton: SCMInputActionButtonDto): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (!actionButton.icon) {
return undefined;
} else if (URI.isUri(actionButton.icon)) {
return URI.revive(actionButton.icon);
} else if (ThemeIcon.isThemeIcon(actionButton.icon)) {
return actionButton.icon;
} else {
const icon = actionButton.icon as { light: UriComponents; dark: UriComponents };
return { light: URI.revive(icon.light), dark: URI.revive(icon.dark) };
}
}
function getIconFromIconDto(iconDto?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
if (iconDto === undefined) {
return undefined;
@ -623,16 +610,6 @@ export class MainThreadSCM implements MainThreadSCMShape {
repository.input.visible = visible;
}
$setInputBoxActionButton(sourceControlHandle: number, actionButton?: SCMInputActionButtonDto | null | undefined): void {
const repository = this._repositories.get(sourceControlHandle);
if (!repository) {
return;
}
repository.input.actionButton = actionButton ? { ...actionButton, icon: getSCMInputBoxActionButtonIcon(actionButton) } : undefined;
}
$showValidationMessage(sourceControlHandle: number, message: string | IMarkdownString, type: InputValidationType) {
const repository = this._repositories.get(sourceControlHandle);
if (!repository) {

View file

@ -1421,12 +1421,6 @@ export interface SCMActionButtonDto {
enabled: boolean;
}
export interface SCMInputActionButtonDto {
command: ICommandDto;
icon?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon;
enabled: boolean;
}
export interface SCMGroupFeatures {
hideWhenEmpty?: boolean;
}
@ -1496,7 +1490,6 @@ export interface MainThreadSCMShape extends IDisposable {
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
$setInputBoxEnablement(sourceControlHandle: number, enabled: boolean): void;
$setInputBoxVisibility(sourceControlHandle: number, visible: boolean): void;
$setInputBoxActionButton(sourceControlHandle: number, actionButton?: SCMInputActionButtonDto | null): void;
$showValidationMessage(sourceControlHandle: number, message: string | IMarkdownString, type: InputValidationType): void;
$setValidationProviderIsEnabled(sourceControlHandle: number, enabled: boolean): void;

View file

@ -58,19 +58,6 @@ function getIconResource(decorations?: vscode.SourceControlResourceThemableDecor
}
}
function getInputBoxActionButtonIcon(actionButton?: vscode.SourceControlInputBoxActionButton): UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon | undefined {
if (!actionButton?.icon) {
return undefined;
} else if (URI.isUri(actionButton.icon)) {
return actionButton.icon;
} else if (ThemeIcon.isThemeIcon(actionButton.icon)) {
return actionButton.icon;
} else {
const icon = actionButton.icon as { light: URI; dark: URI };
return { light: icon.light, dark: icon.dark };
}
}
function getHistoryItemIconDto(historyItem: vscode.SourceControlHistoryItem): UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon | undefined {
if (!historyItem.icon) {
return undefined;
@ -331,36 +318,13 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
this.#proxy.$setInputBoxVisibility(this._sourceControlHandle, visible);
}
private _actionButton: vscode.SourceControlInputBoxActionButton | undefined;
private _actionButtonDisposables = new MutableDisposable<DisposableStore>();
get actionButton(): vscode.SourceControlInputBoxActionButton | undefined {
checkProposedApiEnabled(this._extension, 'scmInputBoxActionButton');
return this._actionButton;
}
set actionButton(actionButton: vscode.SourceControlInputBoxActionButton | undefined) {
checkProposedApiEnabled(this._extension, 'scmInputBoxActionButton');
this._actionButtonDisposables.value = new DisposableStore();
this._actionButton = actionButton;
const internal = actionButton !== undefined ?
{
command: this._commands.converter.toInternal(actionButton.command, this._actionButtonDisposables.value),
icon: getInputBoxActionButtonIcon(actionButton),
enabled: actionButton.enabled
} : undefined;
this.#proxy.$setInputBoxActionButton(this._sourceControlHandle, internal ?? null);
}
get document(): vscode.TextDocument {
checkProposedApiEnabled(this._extension, 'scmTextDocument');
return this.#extHostDocuments.getDocument(this._documentUri);
}
constructor(private _extension: IExtensionDescription, private _commands: ExtHostCommands, _extHostDocuments: ExtHostDocuments, proxy: MainThreadSCMShape, private _sourceControlHandle: number, private _documentUri: URI) {
constructor(private _extension: IExtensionDescription, _extHostDocuments: ExtHostDocuments, proxy: MainThreadSCMShape, private _sourceControlHandle: number, private _documentUri: URI) {
this.#extHostDocuments = _extHostDocuments;
this.#proxy = proxy;
}
@ -702,7 +666,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
query: _rootUri ? `rootUri=${encodeURIComponent(_rootUri.toString())}` : undefined
});
this._inputBox = new ExtHostSCMInputBox(_extension, _commands, _extHostDocuments, this.#proxy, this.handle, inputBoxDocumentUri);
this._inputBox = new ExtHostSCMInputBox(_extension, _extHostDocuments, this.#proxy, this.handle, inputBoxDocumentUri);
this.#proxy.$registerSourceControl(this.handle, _id, _label, _rootUri, inputBoxDocumentUri);
}

View file

@ -2912,7 +2912,6 @@ export class SCMViewPane extends ViewPane {
const repositoryDisposables = new DisposableStore();
repositoryDisposables.add(repository.provider.onDidChange(() => this.updateChildren(repository)));
repositoryDisposables.add(repository.input.onDidChangeActionButton(() => this.updateChildren(repository)));
repositoryDisposables.add(repository.input.onDidChangeVisibility(() => this.updateChildren(repository)));
repositoryDisposables.add(repository.provider.onDidChangeResourceGroups(() => this.updateChildren(repository)));

View file

@ -111,12 +111,6 @@ export interface ISCMInputChangeEvent {
readonly reason?: SCMInputChangeReason;
}
export interface ISCMInputActionButtonDescriptor {
command: Command;
icon?: URI | { light: URI; dark: URI } | ThemeIcon;
enabled: boolean;
}
export interface ISCMActionButtonDescriptor {
command: Command;
secondaryCommands?: Command[][];
@ -149,9 +143,6 @@ export interface ISCMInput {
visible: boolean;
readonly onDidChangeVisibility: Event<boolean>;
actionButton: ISCMInputActionButtonDescriptor | undefined;
readonly onDidChangeActionButton: Event<void>;
setFocus(): void;
readonly onDidChangeFocus: Event<void>;

View file

@ -81,7 +81,6 @@ export const allApiProposals = Object.freeze({
saveEditor: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.saveEditor.d.ts',
scmActionButton: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmActionButton.d.ts',
scmHistoryProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts',
scmInputBoxActionButton: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmInputBoxActionButton.d.ts',
scmSelectedProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts',
scmTextDocument: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmTextDocument.d.ts',
scmValidation: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmValidation.d.ts',

View file

@ -1,19 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/195474
export interface SourceControlInputBoxActionButton {
readonly command: Command;
readonly enabled: boolean;
readonly icon?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
}
export interface SourceControlInputBox {
actionButton?: SourceControlInputBoxActionButton;
}
}