diff --git a/extensions/notebook/src/book/bookTreeView.ts b/extensions/notebook/src/book/bookTreeView.ts index 8c1c994b1b..041b551527 100644 --- a/extensions/notebook/src/book/bookTreeView.ts +++ b/extensions/notebook/src/book/bookTreeView.ts @@ -425,6 +425,8 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider -1) { // check if the notebook is available in already expanded levels. bookItem = parentBook.bookItems.find(b => b.tooltip === notebookPath); @@ -478,9 +481,11 @@ export class BookTreeViewProvider implements vscode.TreeDataProviderfile 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) { + if (!bookItemToExpand || expandedBookItems.includes(bookItemToExpand)) { break; } + // Since we don't have the same structure defined in the toc on disk, + // Check to see if the files are in the same level as the parent -> // increment to reset the depth since parent is in the same level depthOfNotebookInBook++; } @@ -492,6 +497,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider