From 41f856fe89f02465ddb6172cddf634713d9b66be Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 31 Mar 2020 13:13:19 -0700 Subject: [PATCH] Make sure we delete the backup in more cases --- custom-editor-sample/src/pawDrawEditor.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/custom-editor-sample/src/pawDrawEditor.ts b/custom-editor-sample/src/pawDrawEditor.ts index cb0ad522..fad69ef9 100644 --- a/custom-editor-sample/src/pawDrawEditor.ts +++ b/custom-editor-sample/src/pawDrawEditor.ts @@ -200,15 +200,30 @@ export class PawDrawEditorProvider implements vscode.CustomEditorProvider { this.updateWebviews(document); + + if (document.appliedEdits.length === document.savedEdits.length) { + this.deleteBackup(document); + } } async undoEdits(document: PawDrawDocument, _edits: readonly PawDrawEdit[]): Promise { this.updateWebviews(document); + + if (document.appliedEdits.length === document.savedEdits.length) { + this.deleteBackup(document); + } } async revert(document: PawDrawDocument, _edits: vscode.CustomDocumentRevert): Promise { this.updateWebviews(document); this.deleteBackup(document); + + const diskContent = await vscode.workspace.fs.readFile(document.uri); + for (const webviewPanel of this._allWebviews.get(document.uri.toString()) || []) { + this.postMessage(webviewPanel, 'init', { + value: diskContent + }); + } } async backup(document: PawDrawDocument, _cancellation: vscode.CancellationToken): Promise {