Skip to content

Commit 0ef242c

Browse files
authored
Merge pull request #125728 from microsoft/joh/fix/125716
make sure to transform notebook data metadata
2 parents e27b85b + c188ea9 commit 0ef242c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ export namespace NotebookData {
14601460

14611461
export function from(data: vscode.NotebookData): notebooks.NotebookDataDto {
14621462
const res: notebooks.NotebookDataDto = {
1463-
metadata: Object.create(null),
1463+
metadata: data.metadata ?? Object.create(null),
14641464
cells: [],
14651465
};
14661466
for (let cell of data.cells) {

src/vs/workbench/test/browser/api/extHostTypeConverter.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import * as assert from 'assert';
88
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
9-
import { MarkdownString, NotebookCellOutputItem } from 'vs/workbench/api/common/extHostTypeConverters';
9+
import { MarkdownString, NotebookCellOutputItem, NotebookData } from 'vs/workbench/api/common/extHostTypeConverters';
1010
import { isEmptyObject } from 'vs/base/common/types';
1111
import { forEach } from 'vs/base/common/collections';
1212
import { LogLevel as _MainLogLevel } from 'vs/platform/log/common/log';
@@ -83,6 +83,20 @@ suite('ExtHostTypeConverter', function () {
8383
});
8484
});
8585

86+
test('Notebook metadata is ignored when using Notebook Serializer #125716', function () {
87+
88+
const d = new extHostTypes.NotebookData([]);
89+
d.cells.push(new extHostTypes.NotebookCellData(extHostTypes.NotebookCellKind.Code, 'hello', 'fooLang'));
90+
d.metadata = { custom: { foo: 'bar', bar: 123 } };
91+
92+
const dto = NotebookData.from(d);
93+
94+
assert.strictEqual(dto.cells.length, 1);
95+
assert.strictEqual(dto.cells[0].language, 'fooLang');
96+
assert.strictEqual(dto.cells[0].source, 'hello');
97+
assert.deepStrictEqual(dto.metadata, d.metadata);
98+
});
99+
86100
test('NotebookCellOutputItem', function () {
87101

88102
const item = extHostTypes.NotebookCellOutputItem.text('Hello', 'foo/bar');

0 commit comments

Comments
 (0)