Skip to content

Commit 3c666f0

Browse files
authored
Permadelete .vdoc temp files, bypassing the trash (#714)
* Permadelete `.vdoc` temp files, bypassing the trash * CHANGELOG bullet
1 parent 8ad5731 commit 3c666f0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

apps/vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.122.0 (unreleased)
44

5+
- Language server temporary files are now permanently deleted, bypassing the trash can (<https://github.com/quarto-dev/quarto/pull/714>).
56
- Change controls on Positron editor action bar and fix "Render on Save" behavior (<https://github.com/quarto-dev/quarto/pull/706>).
67
- Turn off completions in visual mode in Positron, as a temporary stopgap until we can invest more in LSP features in the visual editor (<https://github.com/quarto-dev/quarto/pull/710>).
78

apps/vscode/src/vdoc/vdoc-tempfile.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,21 @@ export async function virtualDocUriFromTempFile(
7575
};
7676
}
7777

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

0 commit comments

Comments
 (0)