From b36f5a6fd11aa546a8e41ffb63c5178dca00f6f7 Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 18 Jun 2019 16:24:51 +0200 Subject: [PATCH] simplify download --- src/vs/platform/dialogs/common/dialogs.ts | 5 ----- src/vs/workbench/contrib/files/browser/fileActions.ts | 11 ++--------- .../services/dialogs/browser/fileDialogService.ts | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/vs/platform/dialogs/common/dialogs.ts b/src/vs/platform/dialogs/common/dialogs.ts index cb2181914e7..ea57ce91233 100644 --- a/src/vs/platform/dialogs/common/dialogs.ts +++ b/src/vs/platform/dialogs/common/dialogs.ts @@ -59,11 +59,6 @@ export interface ISaveDialogOptions { */ defaultUri?: URI; - /** - * If the defaultUri is not provided use the default file name. - */ - defaultFileName?: string; - /** * A set of file filters that are used by the dialog. Each entry is a human readable label, * like "TypeScript", and an array of extensions. diff --git a/src/vs/workbench/contrib/files/browser/fileActions.ts b/src/vs/workbench/contrib/files/browser/fileActions.ts index e65deb03e95..f12976ad42c 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.ts @@ -36,7 +36,7 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c import { IListService, ListWidget } from 'vs/platform/list/browser/listService'; import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { Schemas } from 'vs/base/common/network'; -import { IDialogService, IConfirmationResult, getConfirmMessage, IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { IDialogService, IConfirmationResult, getConfirmMessage } from 'vs/platform/dialogs/common/dialogs'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { Constants } from 'vs/editor/common/core/uint'; @@ -982,18 +982,11 @@ const downloadFileHandler = (accessor: ServicesAccessor) => { } const explorerContext = getContext(listService.lastFocusedList); const textFileService = accessor.get(ITextFileService); - const fileDialogService = accessor.get(IFileDialogService); if (explorerContext.stat) { const stats = explorerContext.selection.length > 1 ? explorerContext.selection : [explorerContext.stat]; stats.forEach(async s => { - const resource = await fileDialogService.showSaveDialog({ - availableFileSystems: [Schemas.file], - defaultFileName: basename(s.resource.path) - }); - if (resource) { - await textFileService.saveAs(s.resource, resource); - } + await textFileService.saveAs(s.resource, undefined, { availableFileSystems: [Schemas.file] }); }); } }; diff --git a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts index fefbf28bc6e..fe43bbd5c3b 100644 --- a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts @@ -208,7 +208,7 @@ export class FileDialogService implements IFileDialogService { private toNativeSaveDialogOptions(options: ISaveDialogOptions): Electron.SaveDialogOptions { return { - defaultPath: options.defaultUri && options.defaultUri.fsPath || options.defaultFileName, + defaultPath: options.defaultUri && options.defaultUri.fsPath, buttonLabel: options.saveLabel, filters: options.filters, title: options.title -- GitLab