Skip to content

Commit

Permalink
fix: keep compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanba committed Sep 12, 2024
1 parent 490e2b0 commit 2ed7bb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/libro-jupyter/src/contents/content-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/libro-jupyter/src/libro-jupyter-model.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -147,6 +148,15 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
await this.contentsManager.deleteCheckpoint(this.filePath, checkpointID);
}

override loadNotebookContent(): Promise<INotebookContent> {
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;
Expand Down

0 comments on commit 2ed7bb0

Please sign in to comment.