support detail for modal messages, https://github.com/microsoft/vscode/issues/125750
This commit is contained in:
parent
a02815e61b
commit
505dfc7a06
6
src/vs/vscode.d.ts
vendored
6
src/vs/vscode.d.ts
vendored
|
@ -1860,6 +1860,12 @@ declare module 'vscode' {
|
|||
* Indicates that this message should be modal.
|
||||
*/
|
||||
modal?: boolean;
|
||||
|
||||
/**
|
||||
* Human-readable detail message that is rendered less prominent. _Note_ that detail
|
||||
* is only shown for {@link MessageOptions.modal modal} messages.
|
||||
*/
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
|
|||
|
||||
$showMessage(severity: Severity, message: string, options: MainThreadMessageOptions, commands: { title: string; isCloseAffordance: boolean; handle: number; }[]): Promise<number | undefined> {
|
||||
if (options.modal) {
|
||||
return this._showModalMessage(severity, message, commands, options.useCustom);
|
||||
return this._showModalMessage(severity, message, options.detail, commands, options.useCustom);
|
||||
} else {
|
||||
return this._showMessage(severity, message, commands, options.extension);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
|
|||
});
|
||||
}
|
||||
|
||||
private async _showModalMessage(severity: Severity, message: string, commands: { title: string; isCloseAffordance: boolean; handle: number; }[], useCustom?: boolean): Promise<number | undefined> {
|
||||
private async _showModalMessage(severity: Severity, message: string, detail: string | undefined, commands: { title: string; isCloseAffordance: boolean; handle: number; }[], useCustom?: boolean): Promise<number | undefined> {
|
||||
let cancelId: number | undefined = undefined;
|
||||
|
||||
const buttons = commands.map((command, index) => {
|
||||
|
@ -121,7 +121,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
|
|||
cancelId = buttons.length - 1;
|
||||
}
|
||||
|
||||
const { choice } = await this._dialogService.show(severity, message, buttons, { cancelId, custom: useCustom });
|
||||
const { choice } = await this._dialogService.show(severity, message, buttons, { cancelId, custom: useCustom, detail });
|
||||
return choice === commands.length ? undefined : commands[choice].handle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,6 +423,7 @@ export interface MainThreadLanguagesShape extends IDisposable {
|
|||
export interface MainThreadMessageOptions {
|
||||
extension?: IExtensionDescription;
|
||||
modal?: boolean;
|
||||
detail?: string;
|
||||
useCustom?: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,9 @@ export class ExtHostMessageService {
|
|||
if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
|
||||
items = [optionsOrFirstItem, ...rest];
|
||||
} else {
|
||||
options.modal = optionsOrFirstItem && optionsOrFirstItem.modal;
|
||||
options.useCustom = optionsOrFirstItem && optionsOrFirstItem.useCustom;
|
||||
options.modal = optionsOrFirstItem?.modal;
|
||||
options.useCustom = optionsOrFirstItem?.useCustom;
|
||||
options.detail = optionsOrFirstItem?.detail;
|
||||
items = rest;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue