Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store isInteractiveWindowMessageCell at root level #15381

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/interactive-window/systemInfoCell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ export function getFinishConnectMessage(kernelMetadata: KernelConnectionMetadata
}

export function isSysInfoCell(cell: NotebookCell) {
return (
cell.kind === NotebookCellKind.Markup &&
cell.metadata.custom?.metadata &&
cell.metadata.custom.metadata['isInteractiveWindowMessageCell']
);
return cell.kind === NotebookCellKind.Markup && cell.metadata?.isInteractiveWindowMessageCell === true;
}

export class SystemInfoCell {
Expand Down Expand Up @@ -70,7 +66,7 @@ export class SystemInfoCell {
let addedCellIndex: number | undefined;
await chainWithPendingUpdates(this.notebookDocument, (edit) => {
const markdownCell = new NotebookCellData(NotebookCellKind.Markup, message, MARKDOWN_LANGUAGE);
markdownCell.metadata = { custom: { metadata: { isInteractiveWindowMessageCell: true } } };
markdownCell.metadata = { isInteractiveWindowMessageCell: true };
addedCellIndex = this.notebookDocument.cellCount;
const nbEdit = NotebookEdit.insertCells(addedCellIndex, [markdownCell]);
edit.set(this.notebookDocument.uri, [nbEdit]);
Expand All @@ -87,9 +83,7 @@ export class SystemInfoCell {
edit.replace(cell.document.uri, new Range(0, 0, cell.document.lineCount, 0), newMessage);

edit.set(this.notebookDocument!.uri, [
NotebookEdit.updateCellMetadata(cell.index, {
custom: { metadata: { isInteractiveWindowMessageCell: true } }
})
NotebookEdit.updateCellMetadata(cell.index, { isInteractiveWindowMessageCell: true })
]);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/notebooks/export/exportToPythonPlain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ExportToPythonPlain implements IExport {
private exportDocument(document: NotebookDocument): string {
return document
.getCells()
.filter((cell) => !cell.metadata.custom?.metadata?.isInteractiveWindowMessageCell) // We don't want interactive window sys info cells
.filter((cell) => !cell.metadata?.isInteractiveWindowMessageCell) // We don't want interactive window sys info cells
.reduce((previousValue, currentValue) => previousValue + this.exportCell(currentValue), '');
}

Expand Down
Loading