mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
SCM - delete scmInputBoxValueProvider proposal (#199778)
This commit is contained in:
parent
7d76eaf8bd
commit
c5874782c5
|
@ -25,7 +25,6 @@
|
|||
"timeline",
|
||||
"contribMergeEditorMenus",
|
||||
"scmInputBoxActionButton",
|
||||
"scmInputBoxValueProvider",
|
||||
"contribSourceControlInputBoxMenu"
|
||||
],
|
||||
"categories": [
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
"../../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.scmInputBoxValueProvider.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",
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IDisposable, DisposableStore, combinedDisposable, dispose, DisposableMap } from 'vs/base/common/lifecycle';
|
||||
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, IInputValidation, ISCMViewService, InputValidationType, ISCMActionButtonDescriptor, ISCMInputValueProvider, ISCMInputValueProviderContext } from 'vs/workbench/contrib/scm/common/scm';
|
||||
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 { Command } from 'vs/editor/common/languages';
|
||||
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
|
||||
|
@ -452,27 +452,12 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
|
|||
}
|
||||
}
|
||||
|
||||
class MainThreadSCMInputBoxValueProvider implements ISCMInputValueProvider {
|
||||
|
||||
constructor(
|
||||
private readonly proxy: ExtHostSCMShape,
|
||||
private readonly handle: number,
|
||||
readonly label: string,
|
||||
readonly icon?: URI | ThemeIcon | { light: URI; dark: URI }) { }
|
||||
|
||||
provideValue(rootUri: URI, context: ISCMInputValueProviderContext[], token: CancellationToken): Promise<string | undefined> {
|
||||
return this.proxy.$provideInputBoxValue(this.handle, rootUri, context, token);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadSCM)
|
||||
export class MainThreadSCM implements MainThreadSCMShape {
|
||||
|
||||
private readonly _proxy: ExtHostSCMShape;
|
||||
private _repositories = new Map<number, ISCMRepository>();
|
||||
private _repositoryDisposables = new Map<number, IDisposable>();
|
||||
private _inputBoxValueProviders = new DisposableMap<number>();
|
||||
private readonly _disposables = new DisposableStore();
|
||||
|
||||
constructor(
|
||||
|
@ -493,7 +478,6 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
|||
dispose(this._repositoryDisposables.values());
|
||||
this._repositoryDisposables.clear();
|
||||
|
||||
this._inputBoxValueProviders.dispose();
|
||||
this._disposables.dispose();
|
||||
}
|
||||
|
||||
|
@ -543,23 +527,6 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
|||
this._repositories.delete(handle);
|
||||
}
|
||||
|
||||
$registerSourceControlInputBoxValueProvider(handle: number, sourceControlId: string, label: string, icon?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon): void {
|
||||
const provider = new MainThreadSCMInputBoxValueProvider(this._proxy, handle, label, getIconFromIconDto(icon));
|
||||
const disposable = this.scmService.registerSCMInputValueProvider(sourceControlId, provider);
|
||||
|
||||
this._inputBoxValueProviders.set(handle, disposable);
|
||||
}
|
||||
|
||||
$unregisterSourceControlInputBoxValueProvider(handle: number): void {
|
||||
const provider = this._inputBoxValueProviders.get(handle);
|
||||
if (!provider) {
|
||||
return;
|
||||
}
|
||||
|
||||
provider.dispose();
|
||||
this._inputBoxValueProviders.deleteAndDispose(handle);
|
||||
}
|
||||
|
||||
$registerGroups(sourceControlHandle: number, groups: [number /*handle*/, string /*id*/, string /*label*/, SCMGroupFeatures][], splices: SCMRawResourceSplices[]): void {
|
||||
const repository = this._repositories.get(sourceControlHandle);
|
||||
|
||||
|
|
|
@ -1170,10 +1170,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
},
|
||||
createSourceControl(id: string, label: string, rootUri?: vscode.Uri) {
|
||||
return extHostSCM.createSourceControl(extension, id, label, rootUri);
|
||||
},
|
||||
registerSourceControlInputBoxValueProvider(sourceControlId: string, provider: vscode.SourceControlInputBoxValueProvider): vscode.Disposable {
|
||||
checkProposedApiEnabled(extension, 'scmInputBoxValueProvider');
|
||||
return extHostSCM.registerSourceControlInputBoxValueProvider(extension, sourceControlId, provider);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1502,9 +1502,6 @@ export interface MainThreadSCMShape extends IDisposable {
|
|||
$setValidationProviderIsEnabled(sourceControlHandle: number, enabled: boolean): void;
|
||||
|
||||
$onDidChangeHistoryProviderCurrentHistoryItemGroup(sourceControlHandle: number, historyItemGroup: SCMHistoryItemGroupDto | undefined): void;
|
||||
|
||||
$registerSourceControlInputBoxValueProvider(inputBoxValueProviderHandle: number, sourceControlId: string, label: string, icon?: ThemeIcon | UriComponents | { light: UriComponents; dark: UriComponents }): void;
|
||||
$unregisterSourceControlInputBoxValueProvider(inputBoxValueProviderHandle: number): void;
|
||||
}
|
||||
|
||||
export interface MainThreadQuickDiffShape extends IDisposable {
|
||||
|
@ -2219,7 +2216,6 @@ export interface ExtHostTerminalServiceShape {
|
|||
|
||||
export interface ExtHostSCMShape {
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: UriComponents, token: CancellationToken): Promise<UriComponents | null>;
|
||||
$provideInputBoxValue(inputBoxValueProviderHandle: number, rootUri: UriComponents, context: any, token: CancellationToken): Promise<string | undefined>;
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): void;
|
||||
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number, preserveFocus: boolean): Promise<void>;
|
||||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string | IMarkdownString, number] | undefined>;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { DisposableStore, IDisposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto, MainThreadTelemetryShape, SCMGroupFeatures, SCMHistoryItemDto, SCMHistoryItemChangeDto, SCMHistoryItemGroupDto } from './extHost.protocol';
|
||||
|
@ -84,19 +84,6 @@ function getHistoryItemIconDto(historyItem: vscode.SourceControlHistoryItem): Ur
|
|||
}
|
||||
}
|
||||
|
||||
function getSourceControlInputBoxValueProviderIcon(provider: vscode.SourceControlInputBoxValueProvider): UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon | undefined {
|
||||
if (!provider.icon) {
|
||||
return undefined;
|
||||
} else if (URI.isUri(provider.icon)) {
|
||||
return provider.icon;
|
||||
} else if (ThemeIcon.isThemeIcon(provider.icon)) {
|
||||
return provider.icon;
|
||||
} else {
|
||||
const icon = provider.icon as { light: URI; dark: URI };
|
||||
return { light: icon.light, dark: icon.dark };
|
||||
}
|
||||
}
|
||||
|
||||
function compareResourceThemableDecorations(a: vscode.SourceControlResourceThemableDecorations, b: vscode.SourceControlResourceThemableDecorations): number {
|
||||
if (!a.iconPath && !b.iconPath) {
|
||||
return 0;
|
||||
|
@ -808,7 +795,6 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
|||
export class ExtHostSCM implements ExtHostSCMShape {
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
private static _inputBoxValueProviderHandlePool: number = 0;
|
||||
|
||||
private _proxy: MainThreadSCMShape;
|
||||
private readonly _telemetry: MainThreadTelemetryShape;
|
||||
|
@ -818,8 +804,6 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
private readonly _onDidChangeActiveProvider = new Emitter<vscode.SourceControl>();
|
||||
get onDidChangeActiveProvider(): Event<vscode.SourceControl> { return this._onDidChangeActiveProvider.event; }
|
||||
|
||||
private _inputBoxValueProviders: Map<number, vscode.SourceControlInputBoxValueProvider> = new Map<number, vscode.SourceControlInputBoxValueProvider>();
|
||||
|
||||
private _selectedSourceControlHandle: number | undefined;
|
||||
|
||||
constructor(
|
||||
|
@ -894,28 +878,6 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return sourceControl;
|
||||
}
|
||||
|
||||
registerSourceControlInputBoxValueProvider(extension: IExtensionDescription, sourceControlId: string, provider: vscode.SourceControlInputBoxValueProvider): vscode.Disposable {
|
||||
this.logService.trace('ExtHostSCM#registerSourceControlInputBoxValueProvider', extension.identifier.value, provider.label);
|
||||
|
||||
const handle = ExtHostSCM._inputBoxValueProviderHandlePool++;
|
||||
this._inputBoxValueProviders.set(handle, provider);
|
||||
this._proxy.$registerSourceControlInputBoxValueProvider(handle, sourceControlId, provider.label, getSourceControlInputBoxValueProviderIcon(provider));
|
||||
|
||||
return toDisposable(() => {
|
||||
this._proxy.$unregisterSourceControlInputBoxValueProvider(handle);
|
||||
this._inputBoxValueProviders.delete(handle);
|
||||
});
|
||||
}
|
||||
|
||||
async $provideInputBoxValue(inputBoxValueProviderHandle: number, rootUri: UriComponents, context: vscode.SourceControlInputBoxValueProviderContext[], token: CancellationToken): Promise<string | undefined> {
|
||||
const provider = this._inputBoxValueProviders.get(inputBoxValueProviderHandle);
|
||||
if (!provider) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return await provider.provideValue(URI.revive(rootUri), context, token) ?? undefined;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox | undefined {
|
||||
this.logService.trace('ExtHostSCM#getLastInputBox', extension.identifier.value);
|
||||
|
|
|
@ -2095,7 +2095,6 @@ class SCMInputWidget {
|
|||
this.repositoryDisposables.add(Event.filter(this.toolbarContextKeyService.onDidChangeContext, e => e.affectsSome(ctxKeys))(onDidChangeActionButton, this));
|
||||
|
||||
this.repositoryDisposables.add(input.onDidChangeActionButton(onDidChangeActionButton, this));
|
||||
this.repositoryDisposables.add(this.scmService.onDidChangeInputValueProviders(onDidChangeActionButton, this));
|
||||
this.repositoryDisposables.add(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.showInputActionButton'))(onDidChangeActionButton, this));
|
||||
onDidChangeActionButton();
|
||||
|
||||
|
@ -2170,7 +2169,6 @@ class SCMInputWidget {
|
|||
@IKeybindingService private keybindingService: IKeybindingService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ISCMService private readonly scmService: ISCMService,
|
||||
@ISCMViewService private readonly scmViewService: ISCMViewService,
|
||||
@IContextViewService private readonly contextViewService: IContextViewService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
|
|
|
@ -14,7 +14,6 @@ import { ThemeIcon } from 'vs/base/common/themables';
|
|||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { ResourceTree } from 'vs/base/common/resourceTree';
|
||||
import { ISCMHistoryProvider, ISCMHistoryProviderMenus } from 'vs/workbench/contrib/scm/common/history';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.scm';
|
||||
export const VIEW_PANE_ID = 'workbench.scm';
|
||||
|
@ -87,12 +86,6 @@ export interface ISCMInputValueProviderContext {
|
|||
readonly resources: readonly URI[];
|
||||
}
|
||||
|
||||
export interface ISCMInputValueProvider {
|
||||
readonly label: string;
|
||||
readonly icon?: URI | { light: URI; dark: URI } | ThemeIcon;
|
||||
provideValue(rootUri: URI, context: ISCMInputValueProviderContext[], token: CancellationToken): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
export const enum InputValidationType {
|
||||
Error = 0,
|
||||
Warning = 1,
|
||||
|
@ -185,11 +178,6 @@ export interface ISCMService {
|
|||
|
||||
registerSCMProvider(provider: ISCMProvider): ISCMRepository;
|
||||
getRepository(id: string): ISCMRepository | undefined;
|
||||
|
||||
readonly onDidChangeInputValueProviders: Event<void>;
|
||||
|
||||
getDefaultInputValueProvider(repository: ISCMRepository): ISCMInputValueProvider | undefined;
|
||||
registerSCMInputValueProvider(sourceControlId: string, provider: ISCMInputValueProvider): IDisposable;
|
||||
}
|
||||
|
||||
export interface ISCMTitleMenu {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository, IInputValidator, ISCMInputChangeEvent, SCMInputChangeReason, InputValidationType, IInputValidation, ISCMActionButtonDescriptor, ISCMInputValueProvider } from './scm';
|
||||
import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository, IInputValidator, ISCMInputChangeEvent, SCMInputChangeReason, InputValidationType, IInputValidation, ISCMActionButtonDescriptor } from './scm';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
|
@ -365,17 +365,12 @@ export class SCMService implements ISCMService {
|
|||
private inputHistory: SCMInputHistory;
|
||||
private providerCount: IContextKey<number>;
|
||||
|
||||
private readonly _inputValueProviders = new Map<string, Set<ISCMInputValueProvider>>();
|
||||
|
||||
private readonly _onDidAddProvider = new Emitter<ISCMRepository>();
|
||||
readonly onDidAddRepository: Event<ISCMRepository> = this._onDidAddProvider.event;
|
||||
|
||||
private readonly _onDidRemoveProvider = new Emitter<ISCMRepository>();
|
||||
readonly onDidRemoveRepository: Event<ISCMRepository> = this._onDidRemoveProvider.event;
|
||||
|
||||
private readonly _onDidChangeInputValueProviders = new Emitter<void>();
|
||||
readonly onDidChangeInputValueProviders: Event<void> = this._onDidChangeInputValueProviders.event;
|
||||
|
||||
constructor(
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
|
||||
|
@ -411,38 +406,4 @@ export class SCMService implements ISCMService {
|
|||
return this._repositories.get(id);
|
||||
}
|
||||
|
||||
registerSCMInputValueProvider(sourceControlId: string, provider: ISCMInputValueProvider): IDisposable {
|
||||
const providers = this._inputValueProviders.get(sourceControlId) ?? new Set();
|
||||
this._inputValueProviders.set(sourceControlId, providers.add(provider));
|
||||
|
||||
this._onDidChangeInputValueProviders.fire();
|
||||
|
||||
return toDisposable(() => {
|
||||
const providers = this._inputValueProviders.get(sourceControlId)!;
|
||||
|
||||
providers.delete(provider);
|
||||
this._inputValueProviders.set(sourceControlId, providers);
|
||||
|
||||
if (providers.size === 0) {
|
||||
this._inputValueProviders.delete(sourceControlId);
|
||||
}
|
||||
|
||||
this._onDidChangeInputValueProviders.fire();
|
||||
});
|
||||
}
|
||||
|
||||
getDefaultInputValueProvider(repository: ISCMRepository): ISCMInputValueProvider | undefined {
|
||||
if (!repository.provider.rootUri) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const sourceControlId = repository.provider.contextValue;
|
||||
const providers = this._inputValueProviders.get(sourceControlId) ?? new Set();
|
||||
if (providers.size === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return Iterable.first(providers);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ export const allApiProposals = Object.freeze({
|
|||
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',
|
||||
scmInputBoxValueProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmInputBoxValueProvider.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',
|
||||
|
|
|
@ -1,25 +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 namespace scm {
|
||||
export function registerSourceControlInputBoxValueProvider(sourceControlId: string, provider: SourceControlInputBoxValueProvider): Disposable;
|
||||
}
|
||||
|
||||
export interface SourceControlInputBoxValueProviderContext {
|
||||
readonly resourceGroupId: string;
|
||||
readonly resources: readonly Uri[];
|
||||
}
|
||||
|
||||
export interface SourceControlInputBoxValueProvider {
|
||||
readonly label: string;
|
||||
readonly icon?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
|
||||
|
||||
provideValue(rootUri: Uri, context: SourceControlInputBoxValueProviderContext[], token: CancellationToken): ProviderResult<string | undefined>;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue