From 454048dcf98b525a3ca2736b4b589efc5e92b4b0 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 12 Mar 2024 10:13:37 +1100 Subject: [PATCH] Avoid unnecessary workspace edits --- extensions/ipynb/src/notebookAttachmentCleaner.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/ipynb/src/notebookAttachmentCleaner.ts b/extensions/ipynb/src/notebookAttachmentCleaner.ts index cad19f07b29e0..abe4e68fa85e7 100644 --- a/extensions/ipynb/src/notebookAttachmentCleaner.ts +++ b/extensions/ipynb/src/notebookAttachmentCleaner.ts @@ -103,7 +103,9 @@ export class AttachmentCleaner implements vscode.CodeActionProvider { notebookEdits.push(metadataEdit); } } - + if (!notebookEdits.length) { + return; + } const workspaceEdit = new vscode.WorkspaceEdit(); workspaceEdit.set(e.notebook.uri, notebookEdits); @@ -229,7 +231,7 @@ export class AttachmentCleaner implements vscode.CodeActionProvider { this.updateDiagnostics(cell.document.uri, diagnostics); - if (cell.index > -1 && !objectEquals(markdownAttachmentsInUse, cell.metadata.attachments)) { + if (cell.index > -1 && !objectEquals(markdownAttachmentsInUse || {}, cell.metadata.attachments || {})) { const updateMetadata: { [key: string]: any } = deepClone(cell.metadata); if (Object.keys(markdownAttachmentsInUse).length === 0) { updateMetadata.attachments = undefined;