also add showSaveDialog-api, #13807

This commit is contained in:
Johannes Rieken
2017-09-07 17:32:33 +02:00
parent 550e32ea54
commit a731263d95
5 changed files with 62 additions and 14 deletions

View File

@@ -382,6 +382,9 @@ export function createApiFactory(
}),
showOpenDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showOpenDialog(options);
}),
showSaveDialog: proposedApiFunction(extension, options => {
return extHostDialogs.showSaveDialog(options);
})
};

View File

@@ -114,16 +114,22 @@ export interface MainThreadDiagnosticsShape extends IDisposable {
$clear(owner: string): TPromise<any>;
}
export interface MainThreadDialogOptions {
uri?: URI;
export interface MainThreadDialogOpenOptions {
defaultResource?: URI;
openLabel?: string;
openFiles?: boolean;
openFolders?: boolean;
openMany?: boolean;
}
export interface MainThreadDialogSaveOptions {
defaultResource?: URI;
saveLabel?: string;
}
export interface MainThreadDiaglogsShape extends IDisposable {
$showOpenDialog(options: MainThreadDialogOptions): TPromise<string[]>;
$showOpenDialog(options: MainThreadDialogOpenOptions): TPromise<string[]>;
$showSaveDialog(options: MainThreadDialogSaveOptions): TPromise<string>;
}
export interface MainThreadDocumentContentProvidersShape extends IDisposable {

View File

@@ -21,4 +21,10 @@ export class ExtHostDialogs {
return filepaths && filepaths.map(URI.file);
});
}
showSaveDialog(options: vscode.SaveDialogOptions): Thenable<URI> {
return this._proxy.$showSaveDialog(<any>options).then(filepath => {
return filepath && URI.file(filepath);
});
}
}