Removed the unfinished partial implementation of overrideTitle functionality

This commit is contained in:
SebastianMC 2024-01-22 19:54:15 +01:00
parent 124c851989
commit 3000da4edc
3 changed files with 1 additions and 97 deletions

View File

@ -56,7 +56,6 @@ export interface CustomSortGroup {
regexPrefix?: RegExpSpec
exactSuffix?: string
regexSuffix?: RegExpSpec
overrideTitle?: boolean // instead of title, use a derived text for sorting (e.g. regexp matching group).
order?: CustomSortOrder
byMetadataField?: string // for 'by-metadata:' sorting if the order is by metadata alphabetical or reverse
secondaryOrder?: CustomSortOrder

View File

@ -308,36 +308,6 @@ describe('determineSortingGroup', () => {
path: 'Some parent folder/Part:123-icle.md'
});
});
it('should match head and tail, when simple regexp in head and tail, overrideTitle', () => {
// given
const file: TFile = mockTFile('Part:123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
const sortSpec: CustomSortSpec = {
targetFoldersPaths: ['Some parent folder'],
groups: [{
type: CustomSortGroupType.ExactHeadAndTail,
regexPrefix: {
regex: /^Part:\d/i
},
regexSuffix: {
regex: /\d-icle$/i
},
overrideTitle: true // Should be ignored when no advanced regexp
}]
}
// when
const result = determineSortingGroup(file, sortSpec)
// then
expect(result).toEqual({
groupIdx: 0, // Matched!
isFolder: false,
sortString: "Part:123-icle.md",
ctime: MOCK_TIMESTAMP + 555,
mtime: MOCK_TIMESTAMP + 666,
path: 'Some parent folder/Part:123-icle.md'
});
});
it('should match head and tail, when simple regexp in head and and mixed in tail', () => {
// given
const file: TFile = mockTFile('Part:1 1-23.456-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
@ -368,37 +338,6 @@ describe('determineSortingGroup', () => {
path: 'Some parent folder/Part:1 1-23.456-icle.md'
});
});
it('should match head and tail, when simple regexp in head and and mixed in tail, with overrideTitle', () => {
// given
const file: TFile = mockTFile('Part:1 1-23.456-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
const sortSpec: CustomSortSpec = {
targetFoldersPaths: ['Some parent folder'],
groups: [{
type: CustomSortGroupType.ExactHeadAndTail,
regexPrefix: {
regex: /^Part:\d/i
},
regexSuffix: {
regex: / *(\d+(?:-\d+)*).\d\d\d-icle$/i,
normalizerFn: CompoundDashNumberNormalizerFn
},
overrideTitle: true
}]
}
// when
const result = determineSortingGroup(file, sortSpec)
// then
expect(result).toEqual({
groupIdx: 0, // Matched!
isFolder: false,
sortString: "00000001|00000023//",
ctime: MOCK_TIMESTAMP + 555,
mtime: MOCK_TIMESTAMP + 666,
path: 'Some parent folder/Part:1 1-23.456-icle.md'
});
});
it('should match head and tail, when advanced regexp in tail', () => {
// given
const file: TFile = mockTFile('Part:123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
@ -458,38 +397,6 @@ describe('determineSortingGroup', () => {
path: 'Some parent folder/Part 555-6 123-icle.md'
});
});
it('should match head and tail, when advanced regexp in both, head and tail, with overrideTitle', () => {
// given
const file: TFile = mockTFile('Part 555-6 123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
const sortSpec: CustomSortSpec = {
targetFoldersPaths: ['Some parent folder'],
groups: [{
type: CustomSortGroupType.ExactHeadAndTail,
regexPrefix: {
regex: /^Part *(\d+(?:-\d+)*)/i,
normalizerFn: CompoundDashNumberNormalizerFn
},
regexSuffix: {
regex: / *(\d+(?:-\d+)*)-icle$/i,
normalizerFn: CompoundDashNumberNormalizerFn
},
overrideTitle: true
}]
}
// when
const result = determineSortingGroup(file, sortSpec)
// then
expect(result).toEqual({
groupIdx: 0, // Matched!
isFolder: false,
sortString: "00000555|00000006//00000123//",
ctime: MOCK_TIMESTAMP + 555,
mtime: MOCK_TIMESTAMP + 666,
path: 'Some parent folder/Part 555-6 123-icle.md'
});
});
})
describe('CustomSortGroupType.ExactPrefix', () => {
it('should correctly recognize exact prefix', () => {

View File

@ -485,9 +485,7 @@ export const determineSortingGroup = function (entry: TFile | TFolder, spec: Cus
break
}
if (determined && derivedText) {
if (!group.overrideTitle) {
derivedText = derivedText + '//' + entry.name
}
derivedText = derivedText + '//' + entry.name
}
}