Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize InputBoxMessageSeverity API #148961

Merged
merged 1 commit into from May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Expand Up @@ -659,9 +659,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostQuickOpen.showWorkspaceFolderPick(options);
},
showInputBox(options?: vscode.InputBoxOptions, token?: vscode.CancellationToken) {
if (options?.validateInput2) {
checkProposedApiEnabled(extension, 'inputBoxSeverity');
}
return extHostQuickOpen.showInput(options, token);
},
showOpenDialog(options) {
Expand Down
20 changes: 4 additions & 16 deletions src/vs/workbench/api/common/extHostQuickOpen.ts
Expand Up @@ -17,7 +17,6 @@ import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensio
import { coalesce } from 'vs/base/common/arrays';
import Severity from 'vs/base/common/severity';
import { ThemeIcon as ThemeIconUtils } from 'vs/platform/theme/common/themeService';
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';

export type Item = string | QuickPickItem;

Expand Down Expand Up @@ -147,7 +146,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
showInput(options?: InputBoxOptions, token: CancellationToken = CancellationToken.None): Promise<string | undefined> {

// global validate fn used in callback below
this._validateInput = options ? options.validateInput2 ?? options.validateInput : undefined;
this._validateInput = options?.validateInput;

return proxy.$input(options, typeof this._validateInput === 'function', token)
.then(undefined, err => {
Expand Down Expand Up @@ -698,10 +697,9 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx

private _password = false;
private _prompt: string | undefined;
private _validationMessage: string | undefined;
private _validationMessage2: string | InputBoxValidationMessage | undefined;
private _validationMessage: string | InputBoxValidationMessage | undefined;

constructor(private readonly extension: IExtensionDescription, onDispose: () => void) {
constructor(extension: IExtensionDescription, onDispose: () => void) {
super(extension.identifier, onDispose);
this.update({ type: 'inputBox' });
}
Expand All @@ -728,18 +726,8 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
return this._validationMessage;
}

set validationMessage(validationMessage: string | undefined) {
set validationMessage(validationMessage: string | InputBoxValidationMessage | undefined) {
this._validationMessage = validationMessage;
this.update({ validationMessage, severity: validationMessage ? Severity.Error : Severity.Ignore });
}

get validationMessage2() {
return this._validationMessage2;
}

set validationMessage2(validationMessage: string | InputBoxValidationMessage | undefined) {
checkProposedApiEnabled(this.extension, 'inputBoxSeverity');
this._validationMessage2 = validationMessage;
if (!validationMessage) {
this.update({ validationMessage: undefined, severity: Severity.Ignore });
} else if (typeof validationMessage === 'string') {
Expand Down
Expand Up @@ -29,7 +29,6 @@ export const allApiProposals = Object.freeze({
inlineCompletions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts',
inlineCompletionsAdditions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts',
inlineCompletionsNew: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts',
inputBoxSeverity: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inputBoxSeverity.d.ts',
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',
notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts',
notebookContentProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookContentProvider.d.ts',
Expand Down
31 changes: 29 additions & 2 deletions src/vscode-dts/vscode.d.ts
Expand Up @@ -1913,6 +1913,32 @@ declare module 'vscode' {
detail?: string;
}

/**
* Impacts the behavior and appearance of the validation message.
*/
export enum InputBoxValidationSeverity {
Info = 1,
Warning = 2,
Error = 3
}

/**
* Object to configure the behavior of the validation message.
*/
export interface InputBoxValidationMessage {
/**
* The validation message to display.
*/
readonly message: string;

/**
* The severity of the validation message.
* NOTE: When using `InputBoxValidationSeverity.Error`, the user will not be allowed to accept (hit ENTER) the input.
* `Info` and `Warning` will still allow the InputBox to accept the input.
*/
readonly severity: InputBoxValidationSeverity;
}

/**
* Options to configure the behavior of the input box UI.
*/
Expand Down Expand Up @@ -1965,7 +1991,8 @@ declare module 'vscode' {
* @return A human-readable string which is presented as diagnostic message.
* Return `undefined`, `null`, or the empty string when 'value' is valid.
*/
validateInput?(value: string): string | undefined | null | Thenable<string | undefined | null>;
validateInput?(value: string): string | InputBoxValidationMessage | undefined | null |
Thenable<string | InputBoxValidationMessage | undefined | null>;
}

/**
Expand Down Expand Up @@ -10852,7 +10879,7 @@ declare module 'vscode' {
/**
* An optional validation message indicating a problem with the current input value.
*/
validationMessage: string | undefined;
validationMessage: string | InputBoxValidationMessage | undefined;
}

/**
Expand Down
50 changes: 0 additions & 50 deletions src/vscode-dts/vscode.proposed.inputBoxSeverity.d.ts

This file was deleted.