From 1741786554dccb7995e9d3b168017193c4914cd3 Mon Sep 17 00:00:00 2001 From: rebornix Date: Mon, 24 Aug 2020 13:54:30 -0700 Subject: [PATCH] show language info in metadata --- .../contrib/notebook/browser/diff/cellComponents.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts index f65fa0e43ce..65fbd162cec 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts @@ -220,8 +220,12 @@ abstract class AbstractCellRenderer extends Disposable { this._updateFoldingIcon(); } - private _getFormatedJSON(metadata: NotebookCellMetadata) { - const content = JSON.stringify(metadata); + private _getFormatedJSON(metadata: NotebookCellMetadata, language?: string) { + const content = JSON.stringify({ + language, + ...metadata + }); + const edits = format(content, undefined, {}); const metadataSource = applyEdits(content, edits); @@ -230,8 +234,8 @@ abstract class AbstractCellRenderer extends Disposable { private _buildMetadataEditor() { if (this.cell.type === 'modified') { - const originalMetadataSource = this._getFormatedJSON(this.cell.original?.metadata || {}); - const modifiedMetadataSource = this._getFormatedJSON(this.cell.modified?.metadata || {}); + const originalMetadataSource = this._getFormatedJSON(this.cell.original?.metadata || {}, this.cell.original?.language); + const modifiedMetadataSource = this._getFormatedJSON(this.cell.modified?.metadata || {}, this.cell.modified?.language); if (originalMetadataSource !== modifiedMetadataSource) { this._metadataEditor = this.instantiationService.createInstance(DiffEditorWidget, this._metadataEditorContainer!, { ...fixedDiffEditorOptions -- GitLab