Skip to content

Commit 81cf9e9

Browse files
committed
Refactor file deletion to utilize the VS Code Workspace Edit API
1 parent b2dc418 commit 81cf9e9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/vscode/src/commands/delete-command.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ export function delete_command() {
4242
)
4343
}
4444

45-
await vscode.workspace.fs.delete(uri, {
46-
recursive: true
45+
const edit = new vscode.WorkspaceEdit()
46+
edit.deleteFile(uri, {
47+
recursive: true,
48+
ignoreIfNotExists: true
4749
})
50+
const applied = await vscode.workspace.applyEdit(edit)
51+
if (!applied) {
52+
throw new Error('Failed to apply delete edit')
53+
}
4854
} catch (error: any) {
4955
vscode.window.showErrorMessage(
5056
dictionary.error_message.FAILED_TO_DELETE(error.message)

0 commit comments

Comments
 (0)