Skip to content

Commit

Permalink
Exposed Open/Save dialog title on public VSCode Proposed API (#90493)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Ross <alros@microsoft.com>
  • Loading branch information
GustavoASC and alexr00 authored Feb 19, 2020
1 parent 9d27bbe commit 4957d8d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1674,4 +1674,33 @@ declare module 'vscode' {
}

//#endregion

//#region Dialog title: https://github.com/microsoft/vscode/issues/82871

/**
* Options to configure the behaviour of a file open dialog.
*
* * Note 1: A dialog can select files, folders, or both. This is not true for Windows
* which enforces to open either files or folder, but *not both*.
* * Note 2: Explicitly setting `canSelectFiles` and `canSelectFolders` to `false` is futile
* and the editor then silently adjusts the options to select files.
*/
export interface OpenDialogOptions {
/**
* Dialog title
*/
title?: string;
}

/**
* Options to configure the behaviour of a file save dialog.
*/
export interface SaveDialogOptions {
/**
* Dialog title
*/
title?: string;
}

//#endregion
}
6 changes: 4 additions & 2 deletions src/vs/workbench/api/browser/mainThreadDialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class MainThreadDialogs implements MainThreadDiaglogsShape {
canSelectFiles: options.canSelectFiles || (!options.canSelectFiles && !options.canSelectFolders),
canSelectFolders: options.canSelectFolders,
canSelectMany: options.canSelectMany,
defaultUri: options.defaultUri ? URI.revive(options.defaultUri) : undefined
defaultUri: options.defaultUri ? URI.revive(options.defaultUri) : undefined,
title: options.title || undefined
};
if (options.filters) {
result.filters = [];
Expand All @@ -49,7 +50,8 @@ export class MainThreadDialogs implements MainThreadDiaglogsShape {
private static _convertSaveOptions(options: MainThreadDialogSaveOptions): ISaveDialogOptions {
const result: ISaveDialogOptions = {
defaultUri: options.defaultUri ? URI.revive(options.defaultUri) : undefined,
saveLabel: options.saveLabel || undefined
saveLabel: options.saveLabel || undefined,
title: options.title || undefined
};
if (options.filters) {
result.filters = [];
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ export interface MainThreadDialogOpenOptions {
canSelectFolders?: boolean;
canSelectMany?: boolean;
filters?: { [name: string]: string[]; };
title?: string;
}

export interface MainThreadDialogSaveOptions {
defaultUri?: UriComponents;
saveLabel?: string;
filters?: { [name: string]: string[]; };
title?: string;
}

export interface MainThreadDiaglogsShape extends IDisposable {
Expand Down

0 comments on commit 4957d8d

Please sign in to comment.