mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 06:48:17 +00:00
Search ITree cleanup
This commit is contained in:
parent
c37faa8d8e
commit
b19262079b
|
@ -13,7 +13,6 @@ import { IAction } from 'vs/base/common/actions';
|
|||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { IFilter, ISorter, ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { FileKind } from 'vs/platform/files/common/files';
|
||||
|
@ -26,13 +25,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
|||
import { IResourceLabel, ResourceLabels } from 'vs/workbench/browser/labels';
|
||||
import { RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction } from 'vs/workbench/parts/search/browser/searchActions';
|
||||
import { SearchView } from 'vs/workbench/parts/search/browser/searchView';
|
||||
import { FileMatch, FolderMatch, Match, RenderableMatch, searchMatchComparer, SearchModel } from 'vs/workbench/parts/search/common/searchModel';
|
||||
|
||||
export class SearchSorter implements ISorter {
|
||||
public compare(tree: ITree, elementA: RenderableMatch, elementB: RenderableMatch): number {
|
||||
return searchMatchComparer(elementA, elementB);
|
||||
}
|
||||
}
|
||||
import { FileMatch, FolderMatch, Match, RenderableMatch, SearchModel } from 'vs/workbench/parts/search/common/searchModel';
|
||||
|
||||
interface IFolderMatchTemplate {
|
||||
label: IResourceLabel;
|
||||
|
@ -320,10 +313,3 @@ export class SearchAccessibilityProvider implements IAccessibilityProvider<Rende
|
|||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class SearchFilter implements IFilter {
|
||||
|
||||
public isVisible(tree: ITree, element: any): boolean {
|
||||
return !(element instanceof FileMatch || element instanceof FolderMatch) || element.matches().length > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
|||
import { IFileMatch, ITextSearchMatch, OneLineRange, QueryType } from 'vs/platform/search/common/search';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { SearchSorter } from 'vs/workbench/parts/search/browser/searchResultsView';
|
||||
import { FileMatch, Match, SearchResult, RenderableMatch } from 'vs/workbench/parts/search/common/searchModel';
|
||||
import { FileMatch, Match, SearchResult, RenderableMatch, searchMatchComparer } from 'vs/workbench/parts/search/common/searchModel';
|
||||
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { createIterator } from 'vs/workbench/parts/search/browser/searchView';
|
||||
import { ITreeElement } from 'vs/base/browser/ui/tree/tree';
|
||||
|
@ -72,7 +71,7 @@ suite('Search - Viewlet', () => {
|
|||
assert.equal((<Iterator<ITreeElement<RenderableMatch>>>first.value.children).next().value.element.id(), 'file:///c%3A/foo>[2,1 -> 2,2]b');
|
||||
});
|
||||
|
||||
test('Sorter', () => {
|
||||
test('Comparer', () => {
|
||||
let fileMatch1 = aFileMatch('C:\\foo');
|
||||
let fileMatch2 = aFileMatch('C:\\with\\path');
|
||||
let fileMatch3 = aFileMatch('C:\\with\\path\\foo');
|
||||
|
@ -80,16 +79,14 @@ suite('Search - Viewlet', () => {
|
|||
let lineMatch2 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
|
||||
let lineMatch3 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
|
||||
|
||||
let s = new SearchSorter();
|
||||
assert(searchMatchComparer(fileMatch1, fileMatch2) < 0);
|
||||
assert(searchMatchComparer(fileMatch2, fileMatch1) > 0);
|
||||
assert(searchMatchComparer(fileMatch1, fileMatch1) === 0);
|
||||
assert(searchMatchComparer(fileMatch2, fileMatch3) < 0);
|
||||
|
||||
assert(s.compare(null, fileMatch1, fileMatch2) < 0);
|
||||
assert(s.compare(null, fileMatch2, fileMatch1) > 0);
|
||||
assert(s.compare(null, fileMatch1, fileMatch1) === 0);
|
||||
assert(s.compare(null, fileMatch2, fileMatch3) < 0);
|
||||
|
||||
assert(s.compare(null, lineMatch1, lineMatch2) < 0);
|
||||
assert(s.compare(null, lineMatch2, lineMatch1) > 0);
|
||||
assert(s.compare(null, lineMatch2, lineMatch3) === 0);
|
||||
assert(searchMatchComparer(lineMatch1, lineMatch2) < 0);
|
||||
assert(searchMatchComparer(lineMatch2, lineMatch1) > 0);
|
||||
assert(searchMatchComparer(lineMatch2, lineMatch3) === 0);
|
||||
});
|
||||
|
||||
function aFileMatch(path: string, searchResult?: SearchResult, ...lineMatches: ITextSearchMatch[]): FileMatch {
|
||||
|
|
Loading…
Reference in a new issue