Skip to content

Unnecessary file content reading when deleting a file #144889

@pjknkda

Description

@pjknkda

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.65.2 (6b74534)
  • OS Version: Ubuntu 20.04.3 LTS

This issue is acutally discovered in https://github.com/coder/code-server, but I found that the root cause is from the upstream vscode, so I am submitting the issue here.

Steps to Reproduce:

  1. Open a vscode window in the browser.
  2. Try to delete a large file (>100MB)
  3. The deletion takes a long time, or the tab is killed by OOM.

The cause I found is that when deleting a file, vscode keeps the file content into memory to support undo operation, only if the file is not too large. But in the code, vscode read the file content unconditionally at first and then discards it if exceeds the size limit.

let fileContent: IFileContent | undefined;
if (!edit.undoesCreate && !edit.options.folder) {
try {
fileContent = await this._fileService.readFile(edit.oldUri);
} catch (err) {
this._logService.critical(err);
}
}
if (!(typeof edit.options.maxSize === 'number' && fileContent && (fileContent?.size > edit.options.maxSize))) {
undoes.push(new CreateEdit(edit.oldUri, edit.options, fileContent?.value));
}

Related issues from code-server

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions