Skip to content

Commit

Permalink
support detail for modal messages, #125750
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 15, 2021
1 parent ae75761 commit edbc5f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/api/browser/mainThreadMessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) => {
Expand All @@ -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;
}
}
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export interface MainThreadLanguagesShape extends IDisposable {
export interface MainThreadMessageOptions {
extension?: IExtensionDescription;
modal?: boolean;
detail?: string;
useCustom?: boolean;
}

Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/api/common/extHostMessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit edbc5f1

Please sign in to comment.