From 6d95b113d5f2f25fd0ea2f7b5f89b7f0686bcc4a Mon Sep 17 00:00:00 2001 From: Maddy <12754347+MaddyDev@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:35:51 -0700 Subject: [PATCH] fix the logic to check the same level folders (#15143) --- extensions/notebook/src/book/bookTreeView.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extensions/notebook/src/book/bookTreeView.ts b/extensions/notebook/src/book/bookTreeView.ts index 5427d920d6..b1796d1b1d 100644 --- a/extensions/notebook/src/book/bookTreeView.ts +++ b/extensions/notebook/src/book/bookTreeView.ts @@ -451,8 +451,17 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider b.tooltip.indexOf(parentBookPath) > -1) ?? parentBook.bookItems.find(b => path.relative(notebookPath, b.tooltip)?.split(path.sep)?.length === depthOfNotebookInBook); + if (!bookItemToExpand) { - break; + // if the book isn't found, check if the book is in the same level as the parent + // since bookItems will not have them yet, check the sections->file property + bookItemToExpand = parentBook.bookItems.find(b => b.sections?.find(n => notebookFolders[notebookFolders.length - depthOfNotebookInBook - 1].indexOf(n.file.substring(n.file.lastIndexOf('/') + 1)) > -1)); + // book isn't found even in the same level, break out and return. + if (!bookItemToExpand) { + break; + } + // increment to reset the depth since parent is in the same level + depthOfNotebookInBook++; } if (!bookItemToExpand.children) { // We haven't loaded children of this node yet so do that now so we can