Skip to content

Commit

Permalink
explorer: use textFileService
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn authored and sandy081 committed Nov 28, 2019
1 parent 708e581 commit c1205fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/vs/workbench/contrib/files/browser/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
async function deleteFiles(textFileService: ITextFileService, dialogService: IDialogService, configurationService: IConfigurationService, elements: ExplorerItem[], useTrash: boolean, skipConfirm = false): Promise<void> {
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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
};

Expand All @@ -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);
}
};

Expand All @@ -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);
Expand All @@ -998,7 +998,7 @@ const downloadFileHandler = (accessor: ServicesAccessor) => {
defaultUri
});
if (destination) {
await fileService.copy(s.resource, destination);
await textFileService.copy(s.resource, destination);
}
}
});
Expand Down Expand Up @@ -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))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
}

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 } });
Expand Down Expand Up @@ -991,7 +991,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
// Reuse duplicate action if user copies
if (isCopy) {
const incrementalNaming = this.configurationService.getValue<IFilesConfiguration>().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 } });
}
Expand Down

0 comments on commit c1205fe

Please sign in to comment.