Fix search for pinned notebooks (#12719)

* fix search for pinned notebooks

* fix filtering when verifying that a search folder is not a subdirectory from the current folder queries path

* Show book node on pinned notebooks search results

* fix parent node on pinned notebooks search results

* fix search for pinned notebook and modify how pinned notebooks are stored in workspace

* update format of pinned notebooks for users that used the september release version

* removed unused functions

* Address PR comments

* fix parent node for legacy version of jupyter books

* remove cast from book path
This commit is contained in:
Barbara Valdez
2020-10-06 11:54:42 -07:00
committed by GitHub
parent 288288df03
commit 825663fd77
10 changed files with 89 additions and 47 deletions

View File

@@ -270,15 +270,40 @@ export class NotebookExplorerViewPaneContainer extends ViewPaneContainer {
if (treeView.dataProvider) {
let items = await treeView?.dataProvider.getChildren(treeView?.root);
items?.forEach(root => {
if (root.contextValue !== 'pinnedNotebook') {
this.updateViewletsState();
let rootFolder = URI.file(isString(root.tooltip) ? root.tooltip : root.tooltip.value);
this.updateViewletsState();
if (root.contextValue === 'providedBook' || root.contextValue === 'savedBook') {
let rootFolder = URI.file(root.resourceUri.path);
let folderToSearch = { folder: rootFolder };
if (root.tooltip.toString().includes('content')) {
let pattern = {};
pattern['content/**'] = true;
folderToSearch['includePattern'] = pattern;
}
query.folderQueries = query.folderQueries.filter((folder) => {
if (!!folder.includePattern && !folder.includePattern.toString().startsWith('content')) {
//verify if pinned notebook is not opened in Books Viewlet
return path.relative(folder.folder.fsPath, folderToSearch.folder.fsPath) !== '..';
} else {
return true;
}
});
query.folderQueries.push(folderToSearch);
filesToIncludeFiltered = filesToIncludeFiltered + path.join(folderToSearch.folder.fsPath, '**', '*.md') + ',' + path.join(folderToSearch.folder.fsPath, '**', '*.ipynb') + ',';
this.searchView.startSearch(query, null, filesToIncludeFiltered, false, this.searchWidget);
} else {
let pattern = {};
let rootFolder = URI.file(root.resourceUri.path);
let pathToNotebook = isString(root.tooltip) ? root.tooltip : root.tooltip.value;
let baseName = path.join('**', path.basename(pathToNotebook));
pattern[baseName] = true;
let folderToSearch = { folder: rootFolder, includePattern: pattern };
query.folderQueries.push(folderToSearch);
filesToIncludeFiltered = filesToIncludeFiltered + rootFolder + ',';
}
});
if (query.folderQueries.length > 0) {
this.searchView.startSearch(query, null, filesToIncludeFiltered, false, this.searchWidget);
}
}
}
});

View File

@@ -259,7 +259,7 @@ export class NotebookSearchView extends SearchView {
progressComplete();
// Do final render, then expand if just 1 file with less than 50 matches
await this.onSearchResultsChanged();
this.onSearchResultsChanged();
const collapseResults = this.searchConfig.collapseResults;
if (collapseResults !== 'alwaysCollapse' && this.viewModel.searchResult.matches().length === 1) {