diff --git a/extensions/notebook/src/book/bookTocManager.ts b/extensions/notebook/src/book/bookTocManager.ts index 7f1a989fbd..2476a8d9bc 100644 --- a/extensions/notebook/src/book/bookTocManager.ts +++ b/extensions/notebook/src/book/bookTocManager.ts @@ -343,7 +343,9 @@ export class BookTocManager implements IBookTocManager { if (this._sourceBook) { const sectionTOC = this._sourceBook.bookItems[0].findChildSection(notebook.uri); - this.newSection = sectionTOC; + if (sectionTOC) { + this.newSection = sectionTOC; + } } fileName = fileName === undefined ? notebookPath.name : path.parse(fileName).name; this.newSection.file = path.sep.concat(fileName).replace(/\\/g, '/'); diff --git a/extensions/notebook/src/book/bookTreeView.ts b/extensions/notebook/src/book/bookTreeView.ts index c8651a4035..2b0c2596a0 100644 --- a/extensions/notebook/src/book/bookTreeView.ts +++ b/extensions/notebook/src/book/bookTreeView.ts @@ -225,11 +225,11 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider