diff --git a/packages/libro-jupyter/src/contents/content-contribution.ts b/packages/libro-jupyter/src/contents/content-contribution.ts index e7595c2a..2efc7777 100644 --- a/packages/libro-jupyter/src/contents/content-contribution.ts +++ b/packages/libro-jupyter/src/contents/content-contribution.ts @@ -20,13 +20,8 @@ export class LibroJupyterContentContribution implements ContentContribution { currentFileContents.content.nbformat_minor = 5; jupyterModel.currentFileContents = currentFileContents; jupyterModel.filePath = currentFileContents.path; - jupyterModel.id = currentFileContents.path; // use file path as id, will be passed to editor and lsp jupyterModel.lastModified = jupyterModel.currentFileContents.last_modified; - if (jupyterModel.executable) { - jupyterModel.startKernelConnection(); - } - return jupyterModel.currentFileContents.content; } } diff --git a/packages/libro-jupyter/src/libro-jupyter-model.ts b/packages/libro-jupyter/src/libro-jupyter-model.ts index f7cc5e18..552a3e4b 100644 --- a/packages/libro-jupyter/src/libro-jupyter-model.ts +++ b/packages/libro-jupyter/src/libro-jupyter-model.ts @@ -1,3 +1,4 @@ +import type { INotebookContent } from '@difizen/libro-common'; import type { VirtualizedManager } from '@difizen/libro-core'; import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core'; import { @@ -147,6 +148,15 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM await this.contentsManager.deleteCheckpoint(this.filePath, checkpointID); } + override loadNotebookContent(): Promise { + const content = super.loadNotebookContent(); + this.id = this.currentFileContents.path; // use file path as id, will be passed to editor and lsp + if (this.executable && !this.kernelConnecting) { + this.startKernelConnection(); + } + return content; + } + startKernelConnection() { this.kernelConnecting = true; const fileInfo = this.currentFileContents;