Skip to content

Commit

Permalink
edits - better fix microsoft#236984 (microsoft#237685)
Browse files Browse the repository at this point in the history
Restore the semantics of how it used to be in before the change in microsoft#144890
  • Loading branch information
bpasero authored Jan 11, 2025
1 parent 9409b89 commit 37249cb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,18 @@ class DeleteOperation implements IFileOperation {

// read file contents for undo operation. when a file is too large it won't be restored
let fileContent: IFileContent | undefined;
const isSizeLimitExceeded = typeof edit.options.maxSize === 'number' && fileStat.size > edit.options.maxSize;
if (!edit.undoesCreate && !edit.options.folder && !isSizeLimitExceeded) {
try {
fileContent = await this._fileService.readFile(edit.oldUri);
} catch (err) {
this._logService.error(err);
let fileContentExceedsMaxSize = false;
if (!edit.undoesCreate && !edit.options.folder) {
fileContentExceedsMaxSize = typeof edit.options.maxSize === 'number' && fileStat.size > edit.options.maxSize;
if (!fileContentExceedsMaxSize) {
try {
fileContent = await this._fileService.readFile(edit.oldUri);
} catch (err) {
this._logService.error(err);
}
}
}
if (!fileContent || !isSizeLimitExceeded) {
if (!fileContentExceedsMaxSize) {
undoes.push(new CreateEdit(edit.oldUri, edit.options, fileContent?.value));
}
}
Expand Down

0 comments on commit 37249cb

Please sign in to comment.