From f943318042a3b9229049aea86cea04d0ff9c8210 Mon Sep 17 00:00:00 2001 From: rebornix Date: Tue, 22 Sep 2020 17:39:09 -0700 Subject: [PATCH] fix #107146. --- .../notebook/browser/diff/cellComponents.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts index ad89563d76039..cd97de9aa6388 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts @@ -403,7 +403,22 @@ abstract class AbstractCellRenderer extends Disposable { } protected _getFormatedMetadataJSON(metadata: NotebookCellMetadata, language?: string) { - const filteredMetadata: { [key: string]: any } = metadata; + let filteredMetadata: { [key: string]: any } = {}; + + if (this.notebookEditor.textModel) { + const transientMetadata = this.notebookEditor.textModel!.transientOptions.transientMetadata; + + const keys = new Set([...Object.keys(metadata)]); + for (let key of keys) { + if (!(transientMetadata[key as keyof NotebookCellMetadata]) + ) { + filteredMetadata[key] = metadata[key as keyof NotebookCellMetadata]; + } + } + } else { + filteredMetadata = metadata; + } + const content = JSON.stringify({ language, ...filteredMetadata