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: '' });
}

View File

@@ -26,6 +26,7 @@ export const msgBookAlreadyTrusted = localize('msgBookAlreadyTrusted', "Book is
export const msgBookUntrusted = localize('msgBookUntrusted', "Book is no longer trusted in this workspace");
export const msgBookAlreadyUntrusted = localize('msgBookAlreadyUntrusted', "Book is already untrusted in this workspace.");
export const missingTocError = localize('bookInitializeFailed', "Failed to find a Table of Contents file in the specified book.");
export const noBooksSelectedError = localize('noBooksSelected', "No books are currently selected in the viewlet.");
export function missingFileError(title: string): string { return localize('missingFileError', "Missing file : {0}", title); }
export function invalidTocFileError(): string { return localize('InvalidError.tocFile', "Invalid toc file"); }