diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 883b86e3699f9..3ec9e869fd4c4 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -1503,6 +1503,75 @@ declare module 'vscode' { onDidSelectItem?(item: QuickPickItem | string): any; } + /** + * Options to configure the behaviour of a file open dialog. + */ + export interface OpenDialogOptions { + /** + * The resource the dialog shows when opened. + */ + defaultUri?: Uri; + + /** + * A human-readable string for the open button. + */ + openLabel?: string; + + /** + * Only allow to select files. *Note* that not all operating systems support + * to select files and folders in one dialog instance. + */ + openFiles?: boolean; + + /** + * Only allow to select folders. *Note* that not all operating systems support + * to select files and folders in one dialog instance. + */ + openFolders?: boolean; + + /** + * Allow to select many files or folders. + */ + openMany?: boolean; + + /** + * A set of file filters that are shown in the dialog, e.g. + * ```ts + * { + * ['Images']: ['*.png', '*.jpg'] + * ['TypeScript']: ['*.ts', '*.tsx'] + * } + * ``` + */ + filters: { [name: string]: string[] }; + } + + /** + * Options to configure the behaviour of a file save dialog. + */ + export interface SaveDialogOptions { + /** + * The resource the dialog shows when opened. + */ + defaultUri?: Uri; + + /** + * A human-readable string for the save button. + */ + saveLabel?: string; + + /** + * A set of file filters that are shown in the dialog, e.g. + * ```ts + * { + * ['Images']: ['*.png', '*.jpg'] + * ['TypeScript']: ['*.ts', '*.tsx'] + * } + * ``` + */ + filters: { [name: string]: string[] }; + } + /** * Represents an action that is shown with an information, warning, or * error message. @@ -4446,6 +4515,22 @@ declare module 'vscode' { */ export function showQuickPick(items: T[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; + /** + * Shows a file open dialog to the user. + * + * @param options Options that control the dialog. + * @returns A promise that resolves to the selected resources or `undefined`. + */ + export function showOpenDialog(options: OpenDialogOptions): Thenable; + + /** + * Shows a file save dialog to the user. + * + * @param options Options that control the dialog. + * @returns A promise that resolves to the selected resource or `undefined`. + */ + export function showSaveDialog(options: SaveDialogOptions): Thenable; + /** * Opens an input box to ask the user for input. * diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 91d6d321fb112..c6914589fafb9 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -7,93 +7,8 @@ declare module 'vscode' { - /** - * Options to configure the behaviour of a file open dialog. - */ - export interface OpenDialogOptions { - /** - * The resource the dialog shows when opened. - */ - defaultUri?: Uri; - - /** - * A human-readable string for the open button. - */ - openLabel?: string; - - /** - * Only allow to select files. *Note* that not all operating systems support - * to select files and folders in one dialog instance. - */ - openFiles?: boolean; - - /** - * Only allow to select folders. *Note* that not all operating systems support - * to select files and folders in one dialog instance. - */ - openFolders?: boolean; - - /** - * Allow to select many files or folders. - */ - openMany?: boolean; - - /** - * A set of file filters that are shown in the dialog, e.g. - * ```ts - * { - * ['Images']: ['*.png', '*.jpg'] - * ['TypeScript']: ['*.ts', '*.tsx'] - * } - * ``` - */ - filters: { [name: string]: string[] }; - } - - /** - * Options to configure the behaviour of a file save dialog. - */ - export interface SaveDialogOptions { - /** - * The resource the dialog shows when opened. - */ - defaultUri?: Uri; - - /** - * A human-readable string for the save button. - */ - saveLabel?: string; - - /** - * A set of file filters that are shown in the dialog, e.g. - * ```ts - * { - * ['Images']: ['*.png', '*.jpg'] - * ['TypeScript']: ['*.ts', '*.tsx'] - * } - * ``` - */ - filters: { [name: string]: string[] }; - } - export namespace window { - /** - * Shows a file open dialog to the user. - * - * @param options Options that control the dialog. - * @returns A promise that resolves to the selected resources or `undefined`. - */ - export function showOpenDialog(options: OpenDialogOptions): Thenable; - - /** - * Shows a file save dialog to the user. - * - * @param options Options that control the dialog. - * @returns A promise that resolves to the selected resource or `undefined`. - */ - export function showSaveDialog(options: SaveDialogOptions): Thenable; - /** * Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from. * Returns `undefined` if no folder is open. diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 40f44cbc4ee23..11d0d16889f0e 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -356,6 +356,12 @@ export function createApiFactory( showInputBox(options?: vscode.InputBoxOptions, token?: vscode.CancellationToken) { return extHostQuickOpen.showInput(options, token); }, + showOpenDialog(options) { + return extHostDialogs.showOpenDialog(options); + }, + showSaveDialog(options) { + return extHostDialogs.showSaveDialog(options); + }, createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem { return extHostStatusBar.createStatusBarEntry(extension.id, position, priority); }, @@ -385,12 +391,6 @@ export function createApiFactory( sampleFunction: proposedApiFunction(extension, () => { return extHostMessageService.showMessage(extension, Severity.Info, 'Hello Proposed Api!', {}, []); }), - showOpenDialog: proposedApiFunction(extension, options => { - return extHostDialogs.showOpenDialog(options); - }), - showSaveDialog: proposedApiFunction(extension, options => { - return extHostDialogs.showSaveDialog(options); - }) }; // namespace: workspace