From 1172e3b95e8abbc4e8686f6d2a1d7b6697c5ac40 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 28 Nov 2019 17:25:47 +0100 Subject: [PATCH] explorer: use textFileService #43768 --- .../contrib/files/browser/fileActions.ts | 16 ++++++++-------- .../files/browser/views/explorerViewer.ts | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/fileActions.ts b/src/vs/workbench/contrib/files/browser/fileActions.ts index 3bf6af89aa6a6..8fc60ca17e97e 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.ts @@ -143,7 +143,7 @@ export class GlobalNewUntitledFileAction extends Action { } } -async function deleteFiles(textFileService: ITextFileService, dialogService: IDialogService, configurationService: IConfigurationService, fileService: IFileService, elements: ExplorerItem[], useTrash: boolean, skipConfirm = false): Promise { +async function deleteFiles(textFileService: ITextFileService, dialogService: IDialogService, configurationService: IConfigurationService, elements: ExplorerItem[], useTrash: boolean, skipConfirm = false): Promise { let primaryButton: string; if (useTrash) { primaryButton = isWindows ? nls.localize('deleteButtonLabelRecycleBin', "&&Move to Recycle Bin") : nls.localize({ key: 'deleteButtonLabelTrash', comment: ['&& denotes a mnemonic'] }, "&&Move to Trash"); @@ -239,7 +239,7 @@ async function deleteFiles(textFileService: ITextFileService, dialogService: IDi } // Call function - const servicePromise = Promise.all(distinctElements.map(e => fileService.del(e.resource, { useTrash: useTrash, recursive: true }))) + const servicePromise = Promise.all(distinctElements.map(e => textFileService.delete(e.resource, { useTrash: useTrash, recursive: true }))) .then(undefined, (error: any) => { // Handle error to delete file(s) from a modal confirmation dialog let errorMessage: string; @@ -268,7 +268,7 @@ async function deleteFiles(textFileService: ITextFileService, dialogService: IDi skipConfirm = true; - return deleteFiles(textFileService, dialogService, configurationService, fileService, elements, useTrash, skipConfirm); + return deleteFiles(textFileService, dialogService, configurationService, elements, useTrash, skipConfirm); } return Promise.resolve(); @@ -941,7 +941,7 @@ export const moveFileToTrashHandler = async (accessor: ServicesAccessor) => { const explorerService = accessor.get(IExplorerService); const stats = explorerService.getContext(true).filter(s => !s.isRoot); if (stats.length) { - await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, true); + await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), stats, true); } }; @@ -950,7 +950,7 @@ export const deleteFileHandler = async (accessor: ServicesAccessor) => { const stats = explorerService.getContext(true).filter(s => !s.isRoot); if (stats.length) { - await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, false); + await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), stats, false); } }; @@ -975,7 +975,7 @@ export const cutFileHandler = (accessor: ServicesAccessor) => { export const DOWNLOAD_COMMAND_ID = 'explorer.download'; const downloadFileHandler = (accessor: ServicesAccessor) => { - const fileService = accessor.get(IFileService); + const textFileService = accessor.get(ITextFileService); const fileDialogService = accessor.get(IFileDialogService); const explorerService = accessor.get(IExplorerService); const stats = explorerService.getContext(true); @@ -998,7 +998,7 @@ const downloadFileHandler = (accessor: ServicesAccessor) => { defaultUri }); if (destination) { - await fileService.copy(s.resource, destination); + await textFileService.copy(s.resource, destination); } } }); @@ -1047,7 +1047,7 @@ export const pasteFileHandler = async (accessor: ServicesAccessor) => { if (pasteShouldMove) { return await textFileService.move(fileToPaste, targetFile); } else { - return await fileService.copy(fileToPaste, targetFile); + return await textFileService.copy(fileToPaste, targetFile); } } catch (e) { onError(notificationService, new Error(nls.localize('fileDeleted', "The file to paste has been deleted or moved since you copied it. {0}", getErrorMessage(e)))); diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index 7e1d56a9a1ec8..d4500556c2d8b 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -908,7 +908,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { } const copyTarget = joinPath(target.resource, basename(sourceFile)); - const stat = await this.fileService.copy(sourceFile, copyTarget, true); + const stat = await this.textFileService.copy(sourceFile, copyTarget, true); // if we only add one file, just open it directly if (resources.length === 1 && !stat.isDirectory) { this.editorService.openEditor({ resource: stat.resource, options: { pinned: true } }); @@ -991,7 +991,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop { // Reuse duplicate action if user copies if (isCopy) { const incrementalNaming = this.configurationService.getValue().explorer.incrementalNaming; - const stat = await this.fileService.copy(source.resource, findValidPasteFileTarget(target, { resource: source.resource, isDirectory: source.isDirectory, allowOverwrite: false }, incrementalNaming)); + const stat = await this.textFileService.copy(source.resource, findValidPasteFileTarget(target, { resource: source.resource, isDirectory: source.isDirectory, allowOverwrite: false }, incrementalNaming)); if (!stat.isDirectory) { await this.editorService.openEditor({ resource: stat.resource, options: { pinned: true } }); }