Skip to content

Commit 4482c87

Browse files
committed
workaround cyclic dependency issue
1 parent 0065a65 commit 4482c87

4 files changed

Lines changed: 26 additions & 22 deletions

File tree

src/vs/vscode.proposed.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,9 @@ declare module 'vscode' {
12421242
readonly metadata?: Record<string, string | number | boolean>;
12431243

12441244
constructor(outputs: NotebookCellOutputItem[], metadata?: Record<string, string | number | boolean>);
1245+
1246+
//TODO@jrieken HACK to workaround dependency issues...
1247+
toJSON(): any;
12451248
}
12461249

12471250
export enum NotebookCellRunState {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { readonly } from 'vs/base/common/errors';
77
import { Emitter, Event } from 'vs/base/common/event';
88
import { Disposable } from 'vs/base/common/lifecycle';
99
import { MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
10-
import { NotebookCellOutput } from 'vs/workbench/api/common/extHostTypeConverters';
1110
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
1211
import { addIdToOutput, CellEditType, ICellEditOperation, ICellReplaceEdit, INotebookEditData, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1312
import * as vscode from 'vscode';
@@ -62,7 +61,7 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
6261
index,
6362
outputs: outputs.map(output => {
6463
if (extHostTypes.NotebookCellOutput.isNotebookCellOutput(output)) {
65-
return addIdToOutput(NotebookCellOutput.from(output));
64+
return addIdToOutput(output.toJSON());
6665
} else {
6766
return addIdToOutput(output);
6867
}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,23 +1299,7 @@ export namespace LogLevel {
12991299

13001300
export namespace NotebookCellOutput {
13011301
export function from(output: types.NotebookCellOutput): IDisplayOutput {
1302-
1303-
let data: { [key: string]: unknown; } = {};
1304-
let custom: { [key: string]: unknown; } = {};
1305-
let hasMetadata = false;
1306-
1307-
for (let item of output.outputs) {
1308-
data[item.mime] = item.value;
1309-
if (item.metadata) {
1310-
custom[item.mime] = item.metadata;
1311-
hasMetadata = true;
1312-
}
1313-
}
1314-
return {
1315-
outputKind: CellOutputKind.Rich,
1316-
data,
1317-
metadata: hasMetadata ? { custom } : undefined
1318-
};
1302+
return output.toJSON();
13191303
}
13201304
}
13211305

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { URI } from 'vs/base/common/uri';
1414
import { generateUuid } from 'vs/base/common/uuid';
1515
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
1616
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
17-
import * as extHostTypeConverters from 'vs/workbench/api/common/extHostTypeConverters';
18-
import { addIdToOutput, CellEditType, ICellEditOperation } from 'vs/workbench/contrib/notebook/common/notebookCommon';
17+
import { addIdToOutput, CellEditType, ICellEditOperation, IDisplayOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1918
import type * as vscode from 'vscode';
2019

2120
function es5ClassCompat(target: Function): any {
@@ -647,7 +646,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
647646
_type: FileEditType.Cell, metadata, uri, edit: {
648647
editType: CellEditType.Output, index, outputs: outputs.map(output => {
649648
if (NotebookCellOutput.isNotebookCellOutput(output)) {
650-
return addIdToOutput(extHostTypeConverters.NotebookCellOutput.from(output));
649+
return addIdToOutput(output.toJSON());
651650
} else {
652651
return addIdToOutput(output);
653652
}
@@ -2806,6 +2805,25 @@ export class NotebookCellOutput {
28062805
readonly outputs: NotebookCellOutputItem[],
28072806
readonly metadata?: Record<string, string | number | boolean>
28082807
) { }
2808+
2809+
toJSON(): IDisplayOutput {
2810+
let data: { [key: string]: unknown; } = {};
2811+
let custom: { [key: string]: unknown; } = {};
2812+
let hasMetadata = false;
2813+
2814+
for (let item of this.outputs) {
2815+
data[item.mime] = item.value;
2816+
if (item.metadata) {
2817+
custom[item.mime] = item.metadata;
2818+
hasMetadata = true;
2819+
}
2820+
}
2821+
return {
2822+
outputKind: CellOutputKind.Rich,
2823+
data,
2824+
metadata: hasMetadata ? { custom } : undefined
2825+
};
2826+
}
28092827
}
28102828

28112829
export enum CellKind {

0 commit comments

Comments
 (0)