Fix some issues with book tree view (#10521)

This commit is contained in:
Charles Gagnon
2020-05-20 11:54:25 -07:00
committed by GitHub
parent 5f003d996f
commit 14554f0d11

View File

@@ -86,7 +86,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
if (notebookDocuments) {
// update trust state of opened items
notebookDocuments.forEach(document => {
let notebook = this.currentBook.getNotebook(document.uri.fsPath);
let notebook = this.currentBook?.getNotebook(document.uri.fsPath);
if (notebook && this._bookTrustManager.isNotebookTrustedByDefault(document.uri.fsPath)) {
document.setTrusted(true);
}
@@ -235,10 +235,10 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
if (!uri) {
let openDocument = azdata.nb.activeNotebookEditor;
if (openDocument) {
bookItem = this.currentBook.getNotebook(openDocument.document.uri.fsPath);
bookItem = this.currentBook?.getNotebook(openDocument.document.uri.fsPath);
}
} else if (uri.fsPath) {
bookItem = this.currentBook.getNotebook(uri.fsPath);
bookItem = this.currentBook?.getNotebook(uri.fsPath);
}
if (bookItem) {
// Select + focus item in viewlet if books viewlet is already open, or if we pass in variable
@@ -276,7 +276,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}
async saveJupyterBooks(): Promise<void> {
if (this.currentBook.bookPath) {
if (this.currentBook?.bookPath) {
const allFilesFilter = loc.allFiles;
let filter: any = {};
filter[allFilesFilter] = '*';