提交 b36f5a6f 编写于 作者: I isidor

simplify download

上级 ad41bd26
......@@ -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.
......
......@@ -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] });
});
}
};
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册