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 {