diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index 11b8d824..55855367 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.122.0 (unreleased) +- Language server temporary files are now permanently deleted, bypassing the trash can (). - Change controls on Positron editor action bar and fix "Render on Save" behavior (). ## 1.121.0 (Release on 2025-05-02) diff --git a/apps/vscode/src/vdoc/vdoc-tempfile.ts b/apps/vscode/src/vdoc/vdoc-tempfile.ts index 699df311..b016c258 100644 --- a/apps/vscode/src/vdoc/vdoc-tempfile.ts +++ b/apps/vscode/src/vdoc/vdoc-tempfile.ts @@ -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}`);