Fix error when calling getParent (#11252)

This commit is contained in:
Charles Gagnon
2020-07-08 14:23:52 -07:00
committed by GitHub
parent ae908530e2
commit 2a7483c036
2 changed files with 3 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ export interface BookTreeItemFormat {
export class BookTreeItem extends vscode.TreeItem { export class BookTreeItem extends vscode.TreeItem {
private _sections: IJupyterBookSection[]; private _sections: IJupyterBookSection[];
private _uri: string; private _uri: string | undefined;
private _previousUri: string; private _previousUri: string;
private _nextUri: string; private _nextUri: string;
public command: vscode.Command; public command: vscode.Command;
@@ -124,7 +124,7 @@ export class BookTreeItem extends vscode.TreeItem {
return this.book.title; return this.book.title;
} }
public get uri(): string { public get uri(): string | undefined {
return this._uri; return this._uri;
} }

View File

@@ -485,7 +485,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
} }
getParent(element?: BookTreeItem): vscode.ProviderResult<BookTreeItem> { getParent(element?: BookTreeItem): vscode.ProviderResult<BookTreeItem> {
if (element) { if (element?.uri) {
let parentPath: string; let parentPath: string;
parentPath = path.join(element.root, Content, element.uri.substring(0, element.uri.lastIndexOf(path.posix.sep))); parentPath = path.join(element.root, Content, element.uri.substring(0, element.uri.lastIndexOf(path.posix.sep)));
if (parentPath === element.root) { if (parentPath === element.root) {