Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sort Order Option setting to address #27759 #96214

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4ffc5c6
Add Sort Order Option setting to address #27759
leilapearson Apr 27, 2020
928beec
Remove extra exports
leilapearson Apr 27, 2020
7e7ef75
Show args in default keybindings
Tyriar Apr 22, 2020
c5344ab
Prevent unexpected rename cancellation
ChrisPapp Apr 21, 2020
5bb2e2c
Use the cancellation token to trigger rename cancellation
ChrisPapp Apr 23, 2020
31a4db7
Make range in EditorStateCancellationTokenSource readonly
ChrisPapp Apr 23, 2020
bba5100
Fix #96009
jeanp413 Apr 26, 2020
96d11ef
Use DisposableStore
roblourens Apr 27, 2020
a7d6660
Add markdownDeprecationMessage
roblourens Apr 27, 2020
3ee8091
editor - properly resolve iconTheme editor option
bpasero Apr 27, 2020
2bfca5e
:lipstick: editor group perf
bpasero Apr 27, 2020
eadd056
:lipstick: redundant code
bpasero Apr 27, 2020
e55627c
:up: playwright@0.15.0 (#96218)
bpasero Apr 27, 2020
758e12b
Add editorOverviewRuler.background colour customisation point
robertrossmann Mar 30, 2020
73924a7
change all instances of `wordHighligher` to `wordHighlighter`
dustypomerleau Apr 22, 2020
074c0aa
fix https://github.com/microsoft/vscode/issues/96013
jrieken Apr 27, 2020
99d45f3
Fixes #95936: Improve width sizing for tokens inspector widget
alexdima Apr 27, 2020
ee41248
Fix error when invoking `explorer.newFile` while explorer viewlet is …
isidorn Apr 27, 2020
fd636e7
add format notebook command, #96239
jrieken Apr 27, 2020
394bf07
use precondition, #96239
jrieken Apr 27, 2020
42daa7b
localize strings, use category property. fyi @rebornix
jrieken Apr 27, 2020
17787b1
explorer: If there is something being edited via input box make sure …
isidorn Apr 27, 2020
72adb5a
notebook - more (and shared) category label, more nls
jrieken Apr 27, 2020
65b513c
Fix #95143
sandy081 Apr 27, 2020
0edd1d6
add log to askpass ipc
joaomoreno Apr 24, 2020
e5cfb03
git extension api: registerCredentialsProvider
joaomoreno Apr 24, 2020
120daea
wip: use registerCredentialsProvider in github-authentication extension
joaomoreno Apr 24, 2020
fedea4b
move github credential provider to git
joaomoreno Apr 27, 2020
21cec0d
Use a max length since we are inserting the whole msg in the DOM and …
isidorn Apr 27, 2020
bb229f1
Fixes #93370: Add ContinueBracketSearchPredicate and invoke it every …
alexdima Apr 27, 2020
0e6f4de
tune status bar accessibility
isidorn Apr 27, 2020
e8b7a0e
Fixes #95591
alexdima Apr 27, 2020
5adf0c7
Allow Quick Open (Ctrl-P) to Prioritize Exact Case Matches (fix #96122)
bpasero Apr 27, 2020
2ee4fb6
Fixes #94144: Remove special dark theme cursor
alexdima Apr 27, 2020
c1d6136
Fix #93904
sandy081 Apr 27, 2020
d8c838c
fix #96225
bpasero Apr 27, 2020
a90a98a
Show title area when there are buttons (fixes #95703)
chrmarti Apr 27, 2020
3d52ea3
fix #95095
sandy081 Apr 27, 2020
0d9bf4f
add TableOfContentsProvider for none text editors, #95234
jrieken Apr 27, 2020
1b756b0
Show warnings when task types don't match
alexr00 Apr 27, 2020
28b3703
#96064 do not show view focus command when not active
sandy081 Apr 27, 2020
e1bc348
Update do for location based API commands.
dbaeumer Apr 27, 2020
9af31c2
progress - preserve 150ms default delay for window progress (#95615)
bpasero Apr 27, 2020
2306c34
:lipstick:
jrieken Apr 27, 2020
2c77e38
git: use environmentVariableCollection
joaomoreno Apr 27, 2020
335b1b0
git: config.terminalAuthentication
joaomoreno Apr 27, 2020
d64f1d2
git: config.githubAuthentication
joaomoreno Apr 27, 2020
a3809d3
:lipstick:
joaomoreno Apr 27, 2020
8677d6c
fix button codicon colors
joaomoreno Apr 27, 2020
0a7b38a
Fix spacing after when
Tyriar Apr 27, 2020
c18e86b
CallStack: We need the MenuEntryActionViewItem so the icon would get …
isidorn Apr 27, 2020
c2cda6e
#96064 Fix model and view
sandy081 Apr 27, 2020
58e36a5
do not throw error and continue
sandy081 Apr 27, 2020
158cfc7
Update vscode.d.ts
badsyntax Apr 26, 2020
f3d8e31
Throttle status bar spinner animations to save CPU
evangrayk Apr 24, 2020
3662f2b
Treat `.gitignore_global` as an Ignore file by default. Fixes #96079.
johnbillion Apr 24, 2020
7754ccc
rename "Trigger" to "TriggerKind"; see #88230
weinand Apr 27, 2020
47bb655
Disable tasks tests in web
Tyriar Apr 27, 2020
058bb93
fixes #95940
joaomoreno Apr 27, 2020
2025795
Add ref to why test is disabled
Tyriar Apr 27, 2020
550fc69
fix #96256
bpasero Apr 27, 2020
e471148
restore compareFiles and compareFileExtensions
leilapearson Apr 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 376 additions & 36 deletions src/vs/base/common/comparers.ts

Large diffs are not rendered by default.

586 changes: 547 additions & 39 deletions src/vs/base/test/browser/comparers.test.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as dom from 'vs/base/browser/dom';
import { compareFileNames } from 'vs/base/common/comparers';
import { compareFileNamesNumeric } from 'vs/base/common/comparers';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { createMatches, FuzzyScore } from 'vs/base/common/filters';
Expand Down Expand Up @@ -351,7 +351,7 @@ export class FileSorter implements ITreeSorter<IFileStat | IWorkspaceFolder> {
}
if ((a as IFileStat).isDirectory === (b as IFileStat).isDirectory) {
// same type -> compare on names
return compareFileNames(a.name, b.name);
return compareFileNamesNumeric(a.name, b.name);
} else if ((a as IFileStat).isDirectory) {
return -1;
} else {
Expand Down
15 changes: 14 additions & 1 deletion src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IEditorInputFactory, EditorInput, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
import { AutoSaveConfiguration, HotExitConfiguration, FILES_EXCLUDE_CONFIG, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files';
import { VIEWLET_ID, SortOrder, FILE_EDITOR_INPUT_ID, IExplorerService } from 'vs/workbench/contrib/files/common/files';
import { VIEWLET_ID, SortOrder, SortOrderOption, FILE_EDITOR_INPUT_ID, IExplorerService } from 'vs/workbench/contrib/files/common/files';
import { TextFileEditorTracker } from 'vs/workbench/contrib/files/browser/editors/textFileEditorTracker';
import { TextFileSaveErrorHandler } from 'vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
Expand Down Expand Up @@ -398,6 +398,19 @@ configurationRegistry.registerConfiguration({
],
'description': nls.localize('sortOrder', "Controls sorting order of files and folders in the explorer.")
},
'explorer.sortOrderOption': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it possibly to understand the difference between explorer.sortOrder setting and explorer.sortOrderOption?

Copy link
Contributor Author

@leilapearson leilapearson Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort Order Option further refines the sort order. I was hoping the description made that clear - but can certainly reword if it doesn't.

image

Maybe "further refines" would be better wording.

'type': 'string',
'enum': [SortOrderOption.Numeric, SortOrderOption.Upper, SortOrderOption.Lower, SortOrderOption.Mixed, SortOrderOption.Unicode],
'default': SortOrderOption.Numeric,
'enumDescriptions': [
nls.localize('sortOrderOption.numeric', 'Mixes uppercase and lowercase names together. Numbers are sorted numerically, not alphabetically.'),
nls.localize('sortOrderOption.upper', 'Groups uppercase names before lowercase names. Numbers are sorted alphabetically.'),
nls.localize('sortOrderOption.lower', 'Groups lowercase names before uppercase names. Numbers are sorted alphabetically.'),
nls.localize('sortOrderOption.mixed', 'Mixes uppercase and lowercase names together. Numbers are sorted alphabetically.'),
nls.localize('sortOrderOption.unicode', 'Sorts names in unicode order.')
],
'description': nls.localize('SortOrderOption', "Further specifies the file and directory sort order.")
},
'explorer.decorations.colors': {
type: 'boolean',
description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
Expand Down
29 changes: 28 additions & 1 deletion src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { equals, deepClone } from 'vs/base/common/objects';
import * as path from 'vs/base/common/path';
import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { compareFileExtensions, compareFileNames } from 'vs/base/common/comparers';
import { compareFileExtensionsNumeric, compareFileNamesUnicode, compareFileExtensionsUnicode, compareFileExtensionsUpper, compareFileExtensionsLower, compareFileExtensionsMixed, compareFileNamesNumeric, compareFileNamesUpper, compareFileNamesLower, compareFileNamesMixed } from 'vs/base/common/comparers';
import { fillResourceDataTransfers, CodeDataTransfers, extractResources, containsDragType } from 'vs/workbench/browser/dnd';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDragAndDropData, DataTransfers } from 'vs/base/browser/dnd';
Expand Down Expand Up @@ -641,6 +641,33 @@ export class FileSorter implements ITreeSorter<ExplorerItem> {
}

const sortOrder = this.explorerService.sortOrder;
const sortOrderOption = this.explorerService.sortOrderOption;

let compareFileNames;
let compareFileExtensions;
switch (sortOrderOption) {
case 'upper':
compareFileNames = compareFileNamesUpper;
compareFileExtensions = compareFileExtensionsUpper;
break;
case 'lower':
compareFileNames = compareFileNamesLower;
compareFileExtensions = compareFileExtensionsLower;
break;
case 'mixed':
compareFileNames = compareFileNamesMixed;
compareFileExtensions = compareFileExtensionsMixed;
break;
case 'unicode':
compareFileNames = compareFileNamesUnicode;
compareFileExtensions = compareFileExtensionsUnicode;
break;
default:
// 'numeric'
compareFileNames = compareFileNamesNumeric;
compareFileExtensions = compareFileExtensionsNumeric;

}

// Sort Directories
switch (sortOrder) {
Expand Down
27 changes: 21 additions & 6 deletions src/vs/workbench/contrib/files/common/explorerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Event } from 'vs/base/common/event';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { IExplorerService, IFilesConfiguration, SortOrder, IExplorerView } from 'vs/workbench/contrib/files/common/files';
import { IExplorerService, IFilesConfiguration, SortOrder, SortOrderOption, IExplorerView } from 'vs/workbench/contrib/files/common/files';
import { ExplorerItem, ExplorerModel } from 'vs/workbench/contrib/files/common/explorerModel';
import { URI } from 'vs/base/common/uri';
import { FileOperationEvent, FileOperation, IFileService, FileChangesEvent, FILES_EXCLUDE_CONFIG, FileChangeType, IResolveFileOptions } from 'vs/platform/files/common/files';
Expand Down Expand Up @@ -35,6 +35,7 @@ export class ExplorerService implements IExplorerService {
private readonly disposables = new DisposableStore();
private editable: { stat: ExplorerItem, data: IEditableData } | undefined;
private _sortOrder: SortOrder;
private _sortOrderOption: SortOrderOption;
private cutItems: ExplorerItem[] | undefined;
private view: IExplorerView | undefined;
private model: ExplorerModel;
Expand All @@ -48,6 +49,7 @@ export class ExplorerService implements IExplorerService {
@IEditorService private editorService: IEditorService,
) {
this._sortOrder = this.configurationService.getValue('explorer.sortOrder');
this._sortOrderOption = this.configurationService.getValue('explorer.sortOrderOption');

this.model = new ExplorerModel(this.contextService, this.fileService);
this.disposables.add(this.model);
Expand Down Expand Up @@ -83,6 +85,10 @@ export class ExplorerService implements IExplorerService {
return this._sortOrder;
}

get sortOrderOption(): SortOrderOption {
return this._sortOrderOption;
}

registerView(contextProvider: IExplorerView): void {
this.view = contextProvider;
}
Expand Down Expand Up @@ -379,13 +385,22 @@ export class ExplorerService implements IExplorerService {
}

private async onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): Promise<void> {
const configSortOrder = configuration?.explorer?.sortOrder || 'default';
let shouldRefresh = false;

const configSortOrder = configuration?.explorer?.sortOrder || SortOrder.Default;
if (this._sortOrder !== configSortOrder) {
const shouldRefresh = this._sortOrder !== undefined;
shouldRefresh = this._sortOrder !== undefined;
this._sortOrder = configSortOrder;
if (shouldRefresh) {
await this.refresh();
}
}

const configSortOrderOption = configuration?.explorer?.sortOrderOption || SortOrderOption.Numeric;
if (this._sortOrderOption !== configSortOrderOption) {
shouldRefresh = shouldRefresh || this._sortOrderOption !== undefined;
this._sortOrderOption = configSortOrderOption;
}

if (shouldRefresh) {
await this.refresh();
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/vs/workbench/contrib/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface IExplorerService {
_serviceBrand: undefined;
readonly roots: ExplorerItem[];
readonly sortOrder: SortOrder;
readonly sortOrderOption: SortOrderOption;

getContext(respectMultiSelection: boolean): ExplorerItem[];
setEditable(stat: ExplorerItem, data: IEditableData | null): Promise<void>;
Expand Down Expand Up @@ -120,6 +121,7 @@ export interface IFilesConfiguration extends PlatformIFilesConfiguration, IWorkb
enableDragAndDrop: boolean;
confirmDelete: boolean;
sortOrder: SortOrder;
sortOrderOption: SortOrderOption;
decorations: {
colors: boolean;
badges: boolean;
Expand All @@ -142,6 +144,14 @@ export const enum SortOrder {
Modified = 'modified'
}

export const enum SortOrderOption {
Numeric = 'numeric',
Upper = 'upper',
Lower = 'lower',
Mixed = 'mixed',
Unicode = 'unicode',
}

export class TextFileContentProvider extends Disposable implements ITextModelContentProvider {
private readonly fileWatcherDisposable = this._register(new MutableDisposable());

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/scm/browser/repositoryPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { Iterable } from 'vs/base/common/iterator';
import { ICompressedTreeNode, ICompressedTreeElement } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
import { URI } from 'vs/base/common/uri';
import { FileKind } from 'vs/platform/files/common/files';
import { compareFileNames } from 'vs/base/common/comparers';
import { compareFileNamesNumeric } from 'vs/base/common/comparers';
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { IViewDescriptor, IViewDescriptorService } from 'vs/workbench/common/views';
import { localize } from 'vs/nls';
Expand Down Expand Up @@ -352,7 +352,7 @@ export class SCMTreeSorter implements ITreeSorter<TreeElement> {
const oneName = ResourceTree.isResourceNode(one) ? one.name : basename((one as ISCMResource).sourceUri);
const otherName = ResourceTree.isResourceNode(other) ? other.name : basename((other as ISCMResource).sourceUri);

return compareFileNames(oneName, otherName);
return compareFileNamesNumeric(oneName, otherName);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/search/common/searchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { editorMatchesToTextSearchResults, addContextToEditorMatches } from 'vs/
import { withNullAsUndefined } from 'vs/base/common/types';
import { memoize } from 'vs/base/common/decorators';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { compareFileNames, compareFileExtensions, comparePaths } from 'vs/base/common/comparers';
import { compareFileNamesNumeric, compareFileExtensionsNumeric, comparePaths } from 'vs/base/common/comparers';
import { IFileService, IFileStatWithMetadata } from 'vs/platform/files/common/files';

export class Match {
Expand Down Expand Up @@ -666,9 +666,9 @@ export function searchMatchComparer(elementA: RenderableMatch, elementB: Rendera
case SearchSortOrder.CountAscending:
return elementA.count() - elementB.count();
case SearchSortOrder.Type:
return compareFileExtensions(elementA.name(), elementB.name());
return compareFileExtensionsNumeric(elementA.name(), elementB.name());
case SearchSortOrder.FileNames:
return compareFileNames(elementA.name(), elementB.name());
return compareFileNamesNumeric(elementA.name(), elementB.name());
case SearchSortOrder.Modified:
const fileStatA = elementA.fileStat;
const fileStatB = elementB.fileStat;
Expand All @@ -677,7 +677,7 @@ export function searchMatchComparer(elementA: RenderableMatch, elementB: Rendera
}
// Fall through otherwise
default:
return comparePaths(elementA.resource.fsPath, elementB.resource.fsPath) || compareFileNames(elementA.name(), elementB.name());
return comparePaths(elementA.resource.fsPath, elementB.resource.fsPath) || compareFileNamesNumeric(elementA.name(), elementB.name());
}
}

Expand Down