diff --git a/extensions/notebook/src/book/bookPinManager.ts b/extensions/notebook/src/book/bookPinManager.ts index 8bff4b64b9..ee37538337 100644 --- a/extensions/notebook/src/book/bookPinManager.ts +++ b/extensions/notebook/src/book/bookPinManager.ts @@ -6,7 +6,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as constants from './../common/constants'; import { BookTreeItem } from './bookTreeItem'; -import { getPinnedNotebooks, setPinnedBookPathsInConfig, IPinnedNotebook } from '../common/utils'; +import { getPinnedNotebooks, setPinnedBookPathsInConfig, IPinnedNotebook, getNotebookType } from '../common/utils'; export interface IBookPinManager { pinNotebook(notebook: BookTreeItem): Promise; @@ -58,7 +58,7 @@ export class BookPinManager implements IBookPinManager { pinnedBooks.splice(existingBookIndex, 1); modifiedPinnedBooks = true; } else if (existingBookIndex === -1 && operation === PinBookOperation.Pin) { - let addNotebook: IPinnedNotebook = { notebookPath: bookPathToChange, bookPath: notebook.book.root, title: notebook.book.title }; + let addNotebook: IPinnedNotebook = { notebookPath: bookPathToChange, bookPath: getNotebookType(notebook.book) ? notebook.book.root : undefined, title: notebook.book.title }; pinnedBooks.push(addNotebook); modifiedPinnedBooks = true; } diff --git a/extensions/notebook/src/book/bookTreeView.ts b/extensions/notebook/src/book/bookTreeView.ts index ba5c306be6..1d859dff99 100644 --- a/extensions/notebook/src/book/bookTreeView.ts +++ b/extensions/notebook/src/book/bookTreeView.ts @@ -16,7 +16,7 @@ import { Deferred } from '../common/promise'; import { IBookTrustManager, BookTrustManager } from './bookTrustManager'; import * as loc from '../common/localizedConstants'; import * as glob from 'fast-glob'; -import { getPinnedNotebooks, confirmMessageDialog, getNotebookType, FileExtension, IPinnedNotebook, BookTreeItemType } from '../common/utils'; +import { getPinnedNotebooks, getNotebookType, confirmMessageDialog, FileExtension, IPinnedNotebook, BookTreeItemType } from '../common/utils'; import { IBookPinManager, BookPinManager } from './bookPinManager'; import { BookTocManager, IBookTocManager, quickPickResults } from './bookTocManager'; import { CreateBookDialog } from '../dialog/createBookDialog'; @@ -138,7 +138,8 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider book.bookPath === bookTreeItem.book.contentPath)?.getNotebook(bookTreeItem.book.contentPath); + if (itemOpenedInBookTreeView) { + itemOpenedInBookTreeView.contextValue = bookTreeItem.contextValue; + this._onDidChangeTreeData.fire(itemOpenedInBookTreeView.parent); + } } } } @@ -264,7 +272,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider { let notebookPath: string = bookItem.book.contentPath; if (notebookPath) { - let notebookDetails: IPinnedNotebook = bookItem.book.root ? { bookPath: bookItem.book.root, notebookPath: notebookPath, title: bookItem.book.title } : { notebookPath: notebookPath }; + let notebookDetails: IPinnedNotebook = getNotebookType(bookItem.book) === BookTreeItemType.savedBookNotebook ? { bookPath: bookItem.book.root, notebookPath: notebookPath, title: bookItem.book.title } : { notebookPath: notebookPath }; await this.createAndAddBookModel(notebookPath, true, notebookDetails); } }