From bc056cb92c19ca1c7ec413ea60f638a79ce42c5d Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 14 Sep 2017 09:59:52 +0200 Subject: [PATCH] fix some URI.file (#34296) --- .../workbench/parts/files/browser/fileActions.ts | 14 ++++++-------- .../files/common/editors/fileEditorTracker.ts | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 9a2ab3ea142..e859b6521af 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -296,22 +296,20 @@ class RenameFileAction extends BaseRenameAction { } public runAction(newName: string): TPromise { - const dirty = this.textFileService.getDirty().filter(d => paths.isEqualOrParent(d.fsPath, this.element.resource.fsPath, !isLinux /* ignorecase */)); const dirtyRenamed: URI[] = []; return TPromise.join(dirty.map(d => { - const targetPath = paths.join(this.element.parent.resource.fsPath, newName); let renamed: URI; // If the dirty file itself got moved, just reparent it to the target folder if (paths.isEqual(this.element.resource.fsPath, d.fsPath)) { - renamed = URI.file(targetPath); + renamed = this.element.parent.resource.with({ path: targetPath }); } // Otherwise, a parent of the dirty resource got moved, so we have to reparent more complicated. Example: else { - renamed = URI.file(paths.join(targetPath, d.fsPath.substr(this.element.resource.fsPath.length + 1))); + renamed = this.element.parent.resource.with({ path: paths.join(targetPath, d.fsPath.substr(this.element.resource.fsPath.length + 1)) }); } dirtyRenamed.push(renamed); @@ -589,7 +587,7 @@ export class CreateFileAction extends BaseCreateAction { } public runAction(fileName: string): TPromise { - return this.fileService.createFile(URI.file(paths.join(this.element.parent.resource.fsPath, fileName))).then(stat => { + return this.fileService.createFile(this.element.parent.resource.with({ path: paths.join(this.element.parent.resource.fsPath, fileName) })).then(stat => { return this.editorService.openEditor({ resource: stat.resource, options: { pinned: true } }); }, (error) => { this.onErrorWithRetry(error, () => this.runAction(fileName)); @@ -615,7 +613,7 @@ export class CreateFolderAction extends BaseCreateAction { } public runAction(fileName: string): TPromise { - return this.fileService.createFolder(URI.file(paths.join(this.element.parent.resource.fsPath, fileName))).then(null, (error) => { + return this.fileService.createFolder(this.element.parent.resource.with({ path: paths.join(this.element.parent.resource.fsPath, fileName) })).then(null, (error) => { this.onErrorWithRetry(error, () => this.runAction(fileName)); }); } @@ -1046,14 +1044,14 @@ export class DuplicateFileAction extends BaseFileAction { private findTarget(): URI { let name = this.element.name; - let candidate = URI.file(paths.join(this.target.resource.fsPath, name)); + let candidate = this.target.resource.with({ path: paths.join(this.target.resource.fsPath, name) }); while (true) { if (!this.element.root.find(candidate)) { break; } name = this.toCopyName(name, this.element.isDirectory); - candidate = URI.file(paths.join(this.target.resource.fsPath, name)); + candidate = this.target.resource.with({ path: paths.join(this.target.resource.fsPath, name) }); } return candidate; diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts index 52124b9fb7e..5de8984ee4f 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts @@ -206,7 +206,7 @@ export class FileEditorTracker implements IWorkbenchContribution { reopenFileResource = newResource; // file got moved } else { const index = indexOf(resource.fsPath, oldResource.fsPath, !isLinux /* ignorecase */); - reopenFileResource = URI.file(paths.join(newResource.fsPath, resource.fsPath.substr(index + oldResource.fsPath.length + 1))); // parent folder got moved + reopenFileResource = newResource.with({ path: paths.join(newResource.fsPath, resource.fsPath.substr(index + oldResource.fsPath.length + 1)) }); // parent folder got moved } // Reopen