Check treeItem first when building search path in searchJupyterBooks. (#10083)

This commit is contained in:
Cory Rivera
2020-04-20 15:30:52 -07:00
committed by GitHub
parent 15e592647e
commit 097289d94c
2 changed files with 14 additions and 4 deletions

View File

@@ -322,11 +322,20 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}
public async searchJupyterBooks(treeItem?: BookTreeItem): Promise<void> {
if (this.currentBook && this.currentBook.bookPath) {
let folderToSearch = this.currentBook.bookPath;
if (treeItem && treeItem.uri) {
folderToSearch = path.join(folderToSearch, Content, path.dirname(treeItem.uri));
let folderToSearch: string;
if (treeItem && treeItem.book.type !== BookTreeItemType.Notebook) {
if (treeItem.uri) {
folderToSearch = path.join(treeItem.root, Content, path.dirname(treeItem.uri));
} else {
folderToSearch = path.join(treeItem.root, Content);
}
} else if (this.currentBook && !this.currentBook.isNotebook) {
folderToSearch = path.join(this.currentBook.bookPath, Content);
} else {
vscode.window.showErrorMessage(loc.noBooksSelectedError);
}
if (folderToSearch) {
let filesToIncludeFiltered = path.join(folderToSearch, '**', '*.md') + ',' + path.join(folderToSearch, '**', '*.ipynb');
vscode.commands.executeCommand('workbench.action.findInFiles', { filesToInclude: filesToIncludeFiltered, query: '' });
}