mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix search results display (#14265)
* fix search results * fix paths for windows
This commit is contained in:
@@ -38,7 +38,6 @@ import { getOutOfWorkspaceEditorResources } from 'vs/workbench/contrib/search/co
|
|||||||
import { NotebookSearchView } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookSearch';
|
import { NotebookSearchView } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookSearch';
|
||||||
import * as path from 'vs/base/common/path';
|
import * as path from 'vs/base/common/path';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { isString } from 'vs/base/common/types';
|
|
||||||
import { TreeViewPane } from 'vs/workbench/browser/parts/views/treeView';
|
import { TreeViewPane } from 'vs/workbench/browser/parts/views/treeView';
|
||||||
|
|
||||||
export const VIEWLET_ID = 'workbench.view.notebooks';
|
export const VIEWLET_ID = 'workbench.view.notebooks';
|
||||||
@@ -260,7 +259,11 @@ export class NotebookExplorerViewPaneContainer extends ViewPaneContainer {
|
|||||||
this.validateQuery(query).then(() => {
|
this.validateQuery(query).then(() => {
|
||||||
if (this.views.length > 1) {
|
if (this.views.length > 1) {
|
||||||
let filesToIncludeFiltered: string = '';
|
let filesToIncludeFiltered: string = '';
|
||||||
this.views.forEach(async (v) => {
|
// search book results first and then notebooks
|
||||||
|
const pinnedNotebookIndex = this.views.findIndex(view => view.id === 'pinnedBooksView');
|
||||||
|
const viewPanes = this.views;
|
||||||
|
viewPanes.push(viewPanes.splice(pinnedNotebookIndex, 1)[0]);
|
||||||
|
viewPanes.forEach(async (v) => {
|
||||||
if (v instanceof TreeViewPane) {
|
if (v instanceof TreeViewPane) {
|
||||||
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getView(v.id));
|
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getView(v.id));
|
||||||
if (treeView.dataProvider) {
|
if (treeView.dataProvider) {
|
||||||
@@ -268,33 +271,35 @@ export class NotebookExplorerViewPaneContainer extends ViewPaneContainer {
|
|||||||
items?.forEach(root => {
|
items?.forEach(root => {
|
||||||
this.updateViewletsState();
|
this.updateViewletsState();
|
||||||
if (root.contextValue === 'providedBook' || root.contextValue === 'savedBook') {
|
if (root.contextValue === 'providedBook' || root.contextValue === 'savedBook') {
|
||||||
let rootFolder = URI.file(root.resourceUri.path);
|
const rootFolder = URI.file(root.resourceUri.path);
|
||||||
let folderToSearch = { folder: rootFolder };
|
let folderToSearch = { folder: rootFolder };
|
||||||
if (root.tooltip.toString().includes('content')) {
|
if (root.tooltip.toString().includes('content')) {
|
||||||
let pattern = {};
|
let pattern = {};
|
||||||
pattern['content/**'] = true;
|
pattern['content/**'] = true;
|
||||||
folderToSearch['includePattern'] = pattern;
|
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);
|
query.folderQueries.push(folderToSearch);
|
||||||
filesToIncludeFiltered = filesToIncludeFiltered + path.join(folderToSearch.folder.fsPath, '**', '*.md') + ',' + path.join(folderToSearch.folder.fsPath, '**', '*.ipynb') + ',';
|
filesToIncludeFiltered = filesToIncludeFiltered + path.join(folderToSearch.folder.fsPath, '**', '*.md') + ',' + path.join(folderToSearch.folder.fsPath, '**', '*.ipynb') + ',';
|
||||||
} else {
|
} else {
|
||||||
let pattern = {};
|
let pattern = {};
|
||||||
let rootFolder = URI.file(path.dirname(root.resourceUri.path));
|
const rootFolder = URI.file(path.dirname(root.resourceUri.path));
|
||||||
let pathToNotebook = isString(root.tooltip) ? root.tooltip : root.tooltip.value;
|
const baseName = path.join('**', path.basename(root.resourceUri.path)).replace(/\\/g, '/');
|
||||||
let baseName = path.join('**', path.basename(pathToNotebook));
|
let isOpenedInBooksView = false;
|
||||||
pattern[baseName] = true;
|
pattern[baseName] = true;
|
||||||
let folderToSearch = { folder: rootFolder, includePattern: pattern };
|
query.folderQueries.forEach((folder) => {
|
||||||
|
//check for books
|
||||||
|
if ((folder.includePattern === undefined || folder.includePattern['content/**']) && !isOpenedInBooksView) {
|
||||||
|
//verify if pinned notebook is not opened in Books Viewlet
|
||||||
|
const relativePath = path.relative(folder.folder.fsPath, rootFolder.fsPath);
|
||||||
|
isOpenedInBooksView = !relativePath.startsWith('..') || !relativePath.startsWith('.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!isOpenedInBooksView) {
|
||||||
|
const folderToSearch = { folder: rootFolder, includePattern: pattern };
|
||||||
query.folderQueries.push(folderToSearch);
|
query.folderQueries.push(folderToSearch);
|
||||||
filesToIncludeFiltered = filesToIncludeFiltered + rootFolder + ',';
|
filesToIncludeFiltered = filesToIncludeFiltered + rootFolder + ',';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (query.folderQueries.length > 0) {
|
if (query.folderQueries.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user