Skip to content

Permadelete .vdoc temp files, bypassing the trash #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.122.0 (unreleased)

- Language server temporary files are now permanently deleted, bypassing the trash can (<https://github.com/quarto-dev/quarto/pull/714>).
- Change controls on Positron editor action bar and fix "Render on Save" behavior (<https://github.com/quarto-dev/quarto/pull/706>).

## 1.121.0 (Release on 2025-05-02)
Expand Down
17 changes: 13 additions & 4 deletions apps/vscode/src/vdoc/vdoc-tempfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ export async function virtualDocUriFromTempFile(
};
}

// delete a document
/**
* Delete a virtual document's on disk temporary file
*
* Since this is an ephemeral file, we bypass the trash (Trash on Mac, Recycle
* Bin on Windows) and permadelete it instead so our trash isn't cluttered with
* thousands of these files. This should also avoid issues with users on network
* drives, which don't necessarily have access to their Recycle Bin (#708).
*
* @param doc The `TextDocument` to delete
*/
async function deleteDocument(doc: TextDocument) {
try {
const edit = new WorkspaceEdit();
edit.deleteFile(doc.uri);
await workspace.applyEdit(edit);
await workspace.fs.delete(doc.uri, {
useTrash: false
});
} catch (error) {
const msg = error instanceof Error ? error.message : JSON.stringify(error);
console.log(`Error removing vdoc at ${doc.fileName}: ${msg}`);
Expand Down