From 0f748a60b33b4467ee8b31c6923a9d7387bb0a3b Mon Sep 17 00:00:00 2001 From: Barbara Valdez <34872381+barbaravaldez@users.noreply.github.com> Date: Fri, 12 Feb 2021 19:17:22 -0800 Subject: [PATCH] Fix not numbered inconsistency (#14269) * fix not numbered field * fix for adding extra field and removing it from sections * use const for variable * use spread operator to create new object * address pr comments * change function name and simplify * Add comment and put the initializeContents in the finally block --- .../notebook/src/book/bookTocManager.ts | 4 +++- extensions/notebook/src/book/bookTreeView.ts | 2 +- .../notebook/src/book/bookVersionHandler.ts | 20 ++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) 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