Removed support for the experimental sorting methods: `aaa-z` and `a-zzz`. They weren't working correctly.

This commit is contained in:
SebastianMC 2024-02-13 16:24:15 +01:00
parent 53b5895e81
commit 424e56c962
4 changed files with 1 additions and 64 deletions

View File

@ -13,14 +13,10 @@ export enum CustomSortGroupType {
export enum CustomSortOrder { export enum CustomSortOrder {
alphabetical = 1, // = 1 to allow: if (customSortOrder) { ... alphabetical = 1, // = 1 to allow: if (customSortOrder) { ...
alphabeticalLowerFirst,
alphabeticalUpperFirst,
alphabeticalWithFileExt, alphabeticalWithFileExt,
trueAlphabetical, trueAlphabetical,
trueAlphabeticalWithFileExt, trueAlphabeticalWithFileExt,
alphabeticalReverse, alphabeticalReverse,
alphabeticalLowerFirstReverse,
alphabeticalUpperFirstReverse,
alphabeticalReverseWithFileExt, alphabeticalReverseWithFileExt,
trueAlphabeticalReverse, trueAlphabeticalReverse,
trueAlphabeticalReverseWithFileExt, trueAlphabeticalReverseWithFileExt,

View File

@ -49,20 +49,6 @@ export const CollatorCompare = new Intl.Collator(undefined, {
numeric: true, numeric: true,
}).compare; }).compare;
export const CollatorCompareUpperFirst = new Intl.Collator(undefined, {
usage: "sort",
sensitivity: "base",
numeric: true,
caseFirst: "upper"
}).compare;
export const CollatorCompareLowerFirst = new Intl.Collator(undefined, {
usage: "sort",
sensitivity: "base",
numeric: true,
caseFirst: "lower"
}).compare;
export const CollatorTrueAlphabeticalCompare = new Intl.Collator(undefined, { export const CollatorTrueAlphabeticalCompare = new Intl.Collator(undefined, {
usage: "sort", usage: "sort",
sensitivity: "base", sensitivity: "base",
@ -193,16 +179,12 @@ const folderGoesFirstWhenSameBasenameAsFolder = (stringCompareResult: number, a:
const Sorters: { [key in CustomSortOrder]: SorterFn } = { const Sorters: { [key in CustomSortOrder]: SorterFn } = {
[CustomSortOrder.alphabetical]: (a: FIFS, b: FIFS) => CollatorCompare(a.sortString, b.sortString), [CustomSortOrder.alphabetical]: (a: FIFS, b: FIFS) => CollatorCompare(a.sortString, b.sortString),
[CustomSortOrder.alphabeticalLowerFirst]: (a: FIFS, b: FIFS) => CollatorCompareLowerFirst(a.sortString, b.sortString),
[CustomSortOrder.alphabeticalUpperFirst]: (a: FIFS, b: FIFS) => CollatorCompareUpperFirst(a.sortString, b.sortString),
[CustomSortOrder.alphabeticalWithFilesPreferred]: (a: FIFS, b: FIFS) => fileGoesFirstWhenSameBasenameAsFolder(CollatorCompare(a.sortString, b.sortString),a,b), [CustomSortOrder.alphabeticalWithFilesPreferred]: (a: FIFS, b: FIFS) => fileGoesFirstWhenSameBasenameAsFolder(CollatorCompare(a.sortString, b.sortString),a,b),
[CustomSortOrder.alphabeticalWithFoldersPreferred]: (a: FIFS, b: FIFS) => fileGoesFirstWhenSameBasenameAsFolder(CollatorCompare(a.sortString, b.sortString),a,b), [CustomSortOrder.alphabeticalWithFoldersPreferred]: (a: FIFS, b: FIFS) => fileGoesFirstWhenSameBasenameAsFolder(CollatorCompare(a.sortString, b.sortString),a,b),
[CustomSortOrder.alphabeticalWithFileExt]: (a: FIFS, b: FIFS) => CollatorCompare(a.sortStringWithExt, b.sortStringWithExt), [CustomSortOrder.alphabeticalWithFileExt]: (a: FIFS, b: FIFS) => CollatorCompare(a.sortStringWithExt, b.sortStringWithExt),
[CustomSortOrder.trueAlphabetical]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(a.sortString, b.sortString), [CustomSortOrder.trueAlphabetical]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(a.sortString, b.sortString),
[CustomSortOrder.trueAlphabeticalWithFileExt]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(a.sortStringWithExt, b.sortStringWithExt), [CustomSortOrder.trueAlphabeticalWithFileExt]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(a.sortStringWithExt, b.sortStringWithExt),
[CustomSortOrder.alphabeticalReverse]: (a: FIFS, b: FIFS) => CollatorCompare(b.sortString, a.sortString), [CustomSortOrder.alphabeticalReverse]: (a: FIFS, b: FIFS) => CollatorCompare(b.sortString, a.sortString),
[CustomSortOrder.alphabeticalLowerFirstReverse]: (a: FIFS, b: FIFS) => CollatorCompareLowerFirst(b.sortString, a.sortString),
[CustomSortOrder.alphabeticalUpperFirstReverse]: (a: FIFS, b: FIFS) => CollatorCompareUpperFirst(b.sortString, a.sortString),
[CustomSortOrder.alphabeticalReverseWithFileExt]: (a: FIFS, b: FIFS) => CollatorCompare(b.sortStringWithExt, a.sortStringWithExt), [CustomSortOrder.alphabeticalReverseWithFileExt]: (a: FIFS, b: FIFS) => CollatorCompare(b.sortStringWithExt, a.sortStringWithExt),
[CustomSortOrder.trueAlphabeticalReverse]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(b.sortString, a.sortString), [CustomSortOrder.trueAlphabeticalReverse]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(b.sortString, a.sortString),
[CustomSortOrder.trueAlphabeticalReverseWithFileExt]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(b.sortStringWithExt, a.sortStringWithExt), [CustomSortOrder.trueAlphabeticalReverseWithFileExt]: (a: FIFS, b: FIFS) => CollatorTrueAlphabeticalCompare(b.sortStringWithExt, a.sortStringWithExt),

View File

@ -711,15 +711,8 @@ describe('SortingSpecProcessor', () => {
}) })
}) })
const txtInputExoticExperimentalSortAttr: string = ` const txtInputExoticExperimentalSortAttr: string = `
target-folder: upper first
< aaa-z
target-folder: upper first Rev
> aaa-z
target-folder: lower first
< a-zzz
target-folder: lower first Rev
> a-zzz
target-folder: VS Code unicode lexicographic target-folder: VS Code unicode lexicographic
< vsc-unicode < vsc-unicode
target-folder: VS Code unicode lexicographic reverse target-folder: VS Code unicode lexicographic reverse
@ -727,38 +720,6 @@ target-folder: VS Code unicode lexicographic reverse
` `
const expectedSortSpecForExoticExperimentalSorting: { [key: string]: CustomSortSpec } = { const expectedSortSpecForExoticExperimentalSorting: { [key: string]: CustomSortSpec } = {
"upper first": {
defaultOrder: CustomSortOrder.alphabeticalUpperFirst,
groups: [{
type: CustomSortGroupType.Outsiders
}],
outsidersGroupIdx: 0,
targetFoldersPaths: ['upper first']
},
"upper first Rev": {
defaultOrder: CustomSortOrder.alphabeticalUpperFirstReverse,
groups: [{
type: CustomSortGroupType.Outsiders
}],
outsidersGroupIdx: 0,
targetFoldersPaths: ['upper first Rev']
},
"lower first": {
defaultOrder: CustomSortOrder.alphabeticalLowerFirst,
groups: [{
type: CustomSortGroupType.Outsiders
}],
outsidersGroupIdx: 0,
targetFoldersPaths: ['lower first']
},
"lower first Rev": {
defaultOrder: CustomSortOrder.alphabeticalLowerFirstReverse,
groups: [{
type: CustomSortGroupType.Outsiders
}],
outsidersGroupIdx: 0,
targetFoldersPaths: ['lower first Rev']
},
"VS Code unicode lexicographic": { "VS Code unicode lexicographic": {
defaultOrder: CustomSortOrder.vscUnicode, defaultOrder: CustomSortOrder.vscUnicode,
groups: [{ groups: [{

View File

@ -116,10 +116,8 @@ const MAX_SORT_LEVEL: number = 1
// remember about .toLowerCase() before comparison! // remember about .toLowerCase() before comparison!
const OrderLiterals: { [key: string]: CustomSortOrderAscDescPair } = { const OrderLiterals: { [key: string]: CustomSortOrderAscDescPair } = {
'a-zzz': {asc: CustomSortOrder.alphabeticalLowerFirst, desc: CustomSortOrder.alphabeticalLowerFirstReverse},
'a-z.': {asc: CustomSortOrder.alphabeticalWithFileExt, desc: CustomSortOrder.alphabeticalReverseWithFileExt}, 'a-z.': {asc: CustomSortOrder.alphabeticalWithFileExt, desc: CustomSortOrder.alphabeticalReverseWithFileExt},
'a-z': {asc: CustomSortOrder.alphabetical, desc: CustomSortOrder.alphabeticalReverse}, 'a-z': {asc: CustomSortOrder.alphabetical, desc: CustomSortOrder.alphabeticalReverse},
'aaa-z': {asc: CustomSortOrder.alphabeticalUpperFirst, desc: CustomSortOrder.alphabeticalUpperFirstReverse},
'true a-z.': {asc: CustomSortOrder.trueAlphabeticalWithFileExt, desc: CustomSortOrder.trueAlphabeticalReverseWithFileExt}, 'true a-z.': {asc: CustomSortOrder.trueAlphabeticalWithFileExt, desc: CustomSortOrder.trueAlphabeticalReverseWithFileExt},
'true a-z': {asc: CustomSortOrder.trueAlphabetical, desc: CustomSortOrder.trueAlphabeticalReverse}, 'true a-z': {asc: CustomSortOrder.trueAlphabetical, desc: CustomSortOrder.trueAlphabeticalReverse},
'created': {asc: CustomSortOrder.byCreatedTime, desc: CustomSortOrder.byCreatedTimeReverse}, 'created': {asc: CustomSortOrder.byCreatedTime, desc: CustomSortOrder.byCreatedTimeReverse},