Johannes Rieken 2020-09-25 10:34:13 +02:00
parent d014eb1280
commit ea78dd7b9c

View file

@ -71,7 +71,7 @@ class CreateOperation implements IFileOperation {
return new Noop(); // not overwriting, but ignoring, and the target file exists
}
await this._workingCopyFileService.create(this.newUri, this.contents, { overwrite: this.options.overwrite });
return this._instaService.createInstance(DeleteOperation, this.newUri, this.options);
return this._instaService.createInstance(DeleteOperation, this.newUri, this.options, true);
}
}
@ -80,6 +80,7 @@ class DeleteOperation implements IFileOperation {
constructor(
readonly oldUri: URI,
readonly options: WorkspaceFileEditOptions,
private readonly _undoesCreateOperation: boolean,
@IWorkingCopyFileService private readonly _workingCopyFileService: IWorkingCopyFileService,
@IFileService private readonly _fileService: IFileService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ -101,10 +102,12 @@ class DeleteOperation implements IFileOperation {
}
let contents: VSBuffer | undefined;
try {
contents = (await this._fileService.readFile(this.oldUri)).value;
} catch (err) {
this._logService.critical(err);
if (!this._undoesCreateOperation) {
try {
contents = (await this._fileService.readFile(this.oldUri)).value;
} catch (err) {
this._logService.critical(err);
}
}
const useTrash = this._fileService.hasCapability(this.oldUri, FileSystemProviderCapabilities.Trash) && this._configurationService.getValue<boolean>('files.enableTrash');
@ -166,7 +169,7 @@ export class BulkFileEdits {
op = this._instaService.createInstance(RenameOperation, edit.newResource, edit.oldResource, options);
} else if (!edit.newResource && edit.oldResource) {
// delete file
op = this._instaService.createInstance(DeleteOperation, edit.oldResource, options);
op = this._instaService.createInstance(DeleteOperation, edit.oldResource, options, false);
} else if (edit.newResource && !edit.oldResource) {
// create file
op = this._instaService.createInstance(CreateOperation, edit.newResource, options, undefined);