diff --git a/src/vs/workbench/parts/search/browser/searchResultsView.ts b/src/vs/workbench/parts/search/browser/searchResultsView.ts index 87f7ee2457c46ae75f13d6365a4e2d5f695a95ce..0314b85ed153562826a8c2f6ee95b6ceba83c6e7 100644 --- a/src/vs/workbench/parts/search/browser/searchResultsView.ts +++ b/src/vs/workbench/parts/search/browser/searchResultsView.ts @@ -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 0; - } -} diff --git a/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts b/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts index 206449b8b9f9074a94972dfb5678cf3e7ef11a4e..51e291fc8e52caedb2e855b8716e119030d77430 100644 --- a/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts +++ b/src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts @@ -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((>>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 {