提交 479d4e6e 编写于 作者: R Robert Jin

Add string descriptions to SearchSortOrder enum

上级 6c8e4a2d
......@@ -51,7 +51,7 @@ import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contri
import { FileMatchOrMatch, ISearchWorkbenchService, RenderableMatch, SearchWorkbenchService, FileMatch, Match, FolderMatch } from 'vs/workbench/contrib/search/common/searchModel';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ISearchConfiguration, ISearchConfigurationProperties, PANEL_ID, VIEWLET_ID, VIEW_ID, VIEW_CONTAINER, SearchSortOrderConfiguration } from 'vs/workbench/services/search/common/search';
import { ISearchConfiguration, ISearchConfigurationProperties, PANEL_ID, VIEWLET_ID, VIEW_ID, VIEW_CONTAINER, SearchSortOrder } from 'vs/workbench/services/search/common/search';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ExplorerViewPaneContainer } from 'vs/workbench/contrib/files/browser/explorerViewlet';
......@@ -829,8 +829,8 @@ configurationRegistry.registerConfiguration({
},
'search.sortOrder': {
'type': 'string',
'enum': [SearchSortOrderConfiguration.default, SearchSortOrderConfiguration.fileNames, SearchSortOrderConfiguration.type, SearchSortOrderConfiguration.modified, SearchSortOrderConfiguration.countDescending, SearchSortOrderConfiguration.countAscending],
'default': SearchSortOrderConfiguration.default,
'enum': [SearchSortOrder.Default, SearchSortOrder.FileNames, SearchSortOrder.Type, SearchSortOrder.Modified, SearchSortOrder.CountDescending, SearchSortOrder.CountAscending],
'default': SearchSortOrder.Default,
'enumDescriptions': [
nls.localize('searchSortOrder.default', 'Results are sorted by folder and file names, in alphabetical order.'),
nls.localize('searchSortOrder.filesOnly', 'Results are sorted by file names ignoring folder order, in alphabetical order.'),
......
......@@ -34,7 +34,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { TreeResourceNavigator2, WorkbenchObjectTree, getSelectionKeyboardEvent } from 'vs/platform/list/browser/listService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IProgressService, IProgressStep, IProgress } from 'vs/platform/progress/common/progress';
import { IPatternInfo, ISearchComplete, ISearchConfiguration, ISearchConfigurationProperties, ITextQuery, VIEW_ID, VIEWLET_ID, SearchSortOrderConfiguration } from 'vs/workbench/services/search/common/search';
import { IPatternInfo, ISearchComplete, ISearchConfiguration, ISearchConfigurationProperties, ITextQuery, VIEW_ID, VIEWLET_ID, SearchSortOrder } from 'vs/workbench/services/search/common/search';
import { ISearchHistoryService, ISearchHistoryValues } from 'vs/workbench/contrib/search/common/searchHistoryService';
import { diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, editorFindMatchHighlight, editorFindMatchHighlightBorder, listActiveSelectionForeground, foreground } from 'vs/platform/theme/common/colorRegistry';
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
......@@ -196,7 +196,7 @@ export class SearchView extends ViewPane {
});
this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('search.sortOrder')) {
if (this.searchConfig.sortOrder === SearchSortOrderConfiguration.modified) {
if (this.searchConfig.sortOrder === SearchSortOrder.Modified) {
// If changing away from modified, remove all fileStats
// so that updated files are re-retrieved next time.
this.removeFileStats();
......@@ -505,7 +505,7 @@ export class SearchView extends ViewPane {
const collapseResults = this.searchConfig.collapseResults;
if (!event || event.added || event.removed) {
// Refresh whole tree
if (this.searchConfig.sortOrder === SearchSortOrderConfiguration.modified) {
if (this.searchConfig.sortOrder === SearchSortOrder.Modified) {
// Ensure all matches have retrieved their file stat
this.retrieveFileStats()
.then(() => this.tree.setChildren(null, this.createResultIterator(collapseResults)));
......@@ -514,8 +514,8 @@ export class SearchView extends ViewPane {
}
} else {
// If updated counts affect our search order, re-sort the view.
if (this.searchConfig.sortOrder === SearchSortOrderConfiguration.countAscending ||
this.searchConfig.sortOrder === SearchSortOrderConfiguration.countDescending) {
if (this.searchConfig.sortOrder === SearchSortOrder.CountAscending ||
this.searchConfig.sortOrder === SearchSortOrder.CountDescending) {
this.tree.setChildren(null, this.createResultIterator(collapseResults));
} else {
// FileMatch modified, refresh those elements
......@@ -1715,7 +1715,7 @@ export class SearchView extends ViewPane {
}
private onFilesChanged(e: FileChangesEvent): void {
if (!this.viewModel || (this.searchConfig.sortOrder !== SearchSortOrderConfiguration.modified && !e.gotDeleted())) {
if (!this.viewModel || (this.searchConfig.sortOrder !== SearchSortOrder.Modified && !e.gotDeleted())) {
return;
}
......@@ -1727,7 +1727,7 @@ export class SearchView extends ViewPane {
} else {
// Check if the changed file contained matches
const changedMatches = matches.filter(m => e.contains(m.resource));
if (changedMatches.length && this.searchConfig.sortOrder === SearchSortOrderConfiguration.modified) {
if (changedMatches.length && this.searchConfig.sortOrder === SearchSortOrder.Modified) {
// No matches need to be removed, but modified files need to have their file stat updated.
this.updateFileStats(changedMatches).then(() => this.refreshTree());
}
......@@ -1809,7 +1809,7 @@ export class SearchView extends ViewPane {
}
private async updateFileStats(elements: FileMatch[]): Promise<void> {
const files = this.searchResult.matches().map(f => f.resolveFileStat(this.fileService));
const files = elements.map(f => f.resolveFileStat(this.fileService));
await Promise.all(files);
}
......
......@@ -20,7 +20,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IProgress, IProgressStep } from 'vs/platform/progress/common/progress';
import { ReplacePattern } from 'vs/workbench/services/search/common/replace';
import { IFileMatch, IPatternInfo, ISearchComplete, ISearchProgressItem, ISearchConfigurationProperties, ISearchService, ITextQuery, ITextSearchPreviewOptions, ITextSearchMatch, ITextSearchStats, resultIsMatch, ISearchRange, OneLineRange, ITextSearchContext, ITextSearchResult, SearchSortOrderConfiguration } from 'vs/workbench/services/search/common/search';
import { IFileMatch, IPatternInfo, ISearchComplete, ISearchProgressItem, ISearchConfigurationProperties, ISearchService, ITextQuery, ITextSearchPreviewOptions, ITextSearchMatch, ITextSearchStats, resultIsMatch, ISearchRange, OneLineRange, ITextSearchContext, ITextSearchResult, SearchSortOrder } from 'vs/workbench/services/search/common/search';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { overviewRulerFindMatchForeground, minimapFindMatch } from 'vs/platform/theme/common/colorRegistry';
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
......@@ -643,22 +643,22 @@ export class FolderMatchWithResource extends FolderMatch {
* Compares instances of the same match type. Different match types should not be siblings
* and their sort order is undefined.
*/
export function searchMatchComparer(elementA: RenderableMatch, elementB: RenderableMatch, sortOrder: SearchSortOrderConfiguration = SearchSortOrderConfiguration.default): number {
export function searchMatchComparer(elementA: RenderableMatch, elementB: RenderableMatch, sortOrder: SearchSortOrder = SearchSortOrder.Default): number {
if (elementA instanceof FolderMatch && elementB instanceof FolderMatch) {
return elementA.index() - elementB.index();
}
if (elementA instanceof FileMatch && elementB instanceof FileMatch) {
switch (sortOrder) {
case SearchSortOrderConfiguration.countDescending:
case SearchSortOrder.CountDescending:
return elementB.count() - elementA.count();
case SearchSortOrderConfiguration.countAscending:
case SearchSortOrder.CountAscending:
return elementA.count() - elementB.count();
case SearchSortOrderConfiguration.type:
case SearchSortOrder.Type:
return compareFileExtensions(elementA.name(), elementB.name());
case SearchSortOrderConfiguration.fileNames:
case SearchSortOrder.FileNames:
return compareFileNames(elementA.name(), elementB.name());
case SearchSortOrderConfiguration.modified:
case SearchSortOrder.Modified:
const fileStatA = elementA.fileStat;
const fileStatB = elementB.fileStat;
if (fileStatA && fileStatB) {
......
......@@ -9,7 +9,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IFileMatch, ITextSearchMatch, OneLineRange, QueryType, SearchSortOrderConfiguration } from 'vs/workbench/services/search/common/search';
import { IFileMatch, ITextSearchMatch, OneLineRange, QueryType, SearchSortOrder } from 'vs/workbench/services/search/common/search';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { FileMatch, Match, searchMatchComparer, SearchResult } from 'vs/workbench/contrib/search/common/searchModel';
......@@ -90,9 +90,9 @@ suite('Search - Viewlet', () => {
// By default, path < path2
assert(searchMatchComparer(fileMatch1, fileMatch2) < 0);
// By filenames, foo10 > foo1
assert(searchMatchComparer(fileMatch1, fileMatch2, SearchSortOrderConfiguration.fileNames) > 0);
assert(searchMatchComparer(fileMatch1, fileMatch2, SearchSortOrder.FileNames) > 0);
// By type, bar.a < bar.b
assert(searchMatchComparer(fileMatch3, fileMatch4, SearchSortOrderConfiguration.type) < 0);
assert(searchMatchComparer(fileMatch3, fileMatch4, SearchSortOrder.Type) < 0);
});
function aFileMatch(path: string, searchResult?: SearchResult, ...lineMatches: ITextSearchMatch[]): FileMatch {
......
......@@ -311,13 +311,13 @@ export class OneLineRange extends SearchRange {
}
}
export const enum SearchSortOrderConfiguration {
default,
fileNames,
type,
modified,
countDescending,
countAscending
export const enum SearchSortOrder {
Default = 'default',
FileNames = 'fileNames',
Type = 'type',
Modified = 'modified',
CountDescending = 'countDescending',
CountAscending = 'countAscending'
}
export interface ISearchConfigurationProperties {
......@@ -342,7 +342,7 @@ export interface ISearchConfigurationProperties {
searchOnTypeDebouncePeriod: number;
enableSearchEditorPreview: boolean;
searchEditorPreviewForceAbsolutePaths: boolean;
sortOrder: SearchSortOrderConfiguration;
sortOrder: SearchSortOrder;
}
export interface ISearchConfiguration extends IFilesConfiguration {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册