mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 15:35:20 +01:00
fix some URI.file (#34296)
This commit is contained in:
@@ -296,22 +296,20 @@ class RenameFileAction extends BaseRenameAction {
|
||||
}
|
||||
|
||||
public runAction(newName: string): TPromise<any> {
|
||||
|
||||
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<any> {
|
||||
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<any> {
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user