mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
update ITreeElement with ICompressedTreeElement (#23839)
This commit is contained in:
@@ -37,7 +37,8 @@ import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
|||||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||||
import * as errors from 'vs/base/common/errors';
|
import * as errors from 'vs/base/common/errors';
|
||||||
import { NotebookSearchWidget } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookSearchWidget';
|
import { NotebookSearchWidget } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookSearchWidget';
|
||||||
import { ITreeElement, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree';
|
import { ICompressedTreeElement } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
|
||||||
|
import { ITreeContextMenuEvent, ObjectTreeElementCollapseState } from 'vs/base/browser/ui/tree/tree';
|
||||||
import { Iterable } from 'vs/base/common/iterator';
|
import { Iterable } from 'vs/base/common/iterator';
|
||||||
import { searchClearIcon, searchCollapseAllIcon, searchExpandAllIcon, searchStopIcon } from 'vs/workbench/contrib/search/browser/searchIcons';
|
import { searchClearIcon, searchCollapseAllIcon, searchExpandAllIcon, searchStopIcon } from 'vs/workbench/contrib/search/browser/searchIcons';
|
||||||
import { Action, IAction } from 'vs/base/common/actions';
|
import { Action, IAction } from 'vs/base/common/actions';
|
||||||
@@ -430,45 +431,49 @@ export class NotebookSearchView extends SearchView {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSearchResultIterator(collapseResults: ISearchConfigurationProperties['collapseResults']): Iterable<ITreeElement<RenderableMatch>> {
|
private createSearchResultIterator(collapseResults: ISearchConfigurationProperties['collapseResults']): Iterable<ICompressedTreeElement<RenderableMatch>> {
|
||||||
const folderMatches = this.searchResult.folderMatches()
|
const folderMatches = this.searchResult.folderMatches()
|
||||||
.filter(fm => !fm.isEmpty())
|
.filter(fm => !fm.isEmpty())
|
||||||
.sort(searchMatchComparer);
|
.sort(searchMatchComparer);
|
||||||
|
|
||||||
if (folderMatches.length === 1) {
|
if (folderMatches.length === 1) {
|
||||||
return this.createSearchFolderIterator(folderMatches[0], collapseResults);
|
return this.createSearchFolderIterator(folderMatches[0], collapseResults, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Iterable.map(folderMatches, folderMatch => {
|
return Iterable.map(folderMatches, folderMatch => {
|
||||||
const children = this.createSearchFolderIterator(folderMatch, collapseResults);
|
const children = this.createSearchFolderIterator(folderMatch, collapseResults, true);
|
||||||
return <ITreeElement<RenderableMatch>>{ element: folderMatch, children };
|
return <ICompressedTreeElement<RenderableMatch>>{ element: folderMatch, children };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSearchFolderIterator(folderMatch: FolderMatch, collapseResults: ISearchConfigurationProperties['collapseResults']): Iterable<ITreeElement<RenderableMatch>> {
|
private createSearchFolderIterator(folderMatch: FolderMatch, collapseResults: ISearchConfigurationProperties['collapseResults'], childFolderIncompressible: boolean): Iterable<ICompressedTreeElement<RenderableMatch>> {
|
||||||
const sortOrder = this.searchConfig.sortOrder;
|
const sortOrder = this.searchConfig.sortOrder;
|
||||||
const matches = folderMatch.matches().sort((a, b) => searchMatchComparer(a, b, sortOrder));
|
|
||||||
|
|
||||||
return Iterable.map(matches, fileMatch => {
|
const matchArray = this.isTreeLayoutViewVisible ? folderMatch.matches() : folderMatch.allDownstreamFileMatches();
|
||||||
//const children = this.createFileIterator(fileMatch);
|
const matches = matchArray.sort((a, b) => searchMatchComparer(a, b, sortOrder));
|
||||||
let nodeExists = true;
|
|
||||||
try { this.tree.getNode(fileMatch); } catch (e) { nodeExists = false; }
|
|
||||||
|
|
||||||
const collapsed = nodeExists ? undefined :
|
return Iterable.map(matches, match => {
|
||||||
(collapseResults === 'alwaysCollapse' || (fileMatch.matches().length > 10 && collapseResults !== 'alwaysExpand'));
|
let children;
|
||||||
|
if (match instanceof FileMatch) {
|
||||||
|
children = this.createSearchFileIterator(match);
|
||||||
|
} else {
|
||||||
|
children = this.createSearchFolderIterator(match, collapseResults, false);
|
||||||
|
}
|
||||||
|
|
||||||
return <ITreeElement<RenderableMatch>>{ element: fileMatch, undefined, collapsed, collapsible: false };
|
const collapsed = (collapseResults === 'alwaysCollapse' || (match.count() > 10 && collapseResults !== 'alwaysExpand')) ? ObjectTreeElementCollapseState.PreserveOrCollapsed : ObjectTreeElementCollapseState.PreserveOrExpanded;
|
||||||
|
|
||||||
|
return <ICompressedTreeElement<RenderableMatch>>{ element: match, children, collapsed, incompressible: (match instanceof FileMatch) ? true : childFolderIncompressible };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSearchFileIterator(fileMatch: FileMatch): Iterable<ITreeElement<RenderableMatch>> {
|
private createSearchFileIterator(fileMatch: FileMatch): Iterable<ICompressedTreeElement<RenderableMatch>> {
|
||||||
const matches = fileMatch.matches().sort(searchMatchComparer);
|
const matches = fileMatch.matches().sort(searchMatchComparer);
|
||||||
return Iterable.map(matches, r => (<ITreeElement<RenderableMatch>>{ element: r }));
|
return Iterable.map(matches, r => (<ICompressedTreeElement<RenderableMatch>>{ element: r }));
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSearchIterator(match: FolderMatch | FileMatch | SearchResult, collapseResults: ISearchConfigurationProperties['collapseResults']): Iterable<ITreeElement<RenderableMatch>> {
|
private createSearchIterator(match: FolderMatch | FileMatch | SearchResult, collapseResults: ISearchConfigurationProperties['collapseResults']): Iterable<ICompressedTreeElement<RenderableMatch>> {
|
||||||
return match instanceof SearchResult ? this.createSearchResultIterator(collapseResults) :
|
return match instanceof SearchResult ? this.createSearchResultIterator(collapseResults) :
|
||||||
match instanceof FolderMatch ? this.createSearchFolderIterator(match, collapseResults) :
|
match instanceof FolderMatch ? this.createSearchFolderIterator(match, collapseResults, false) :
|
||||||
this.createSearchFileIterator(match);
|
this.createSearchFileIterator(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user