From 3000da4edca3c487bd93f7f368ca5f72664c7147 Mon Sep 17 00:00:00 2001 From: SebastianMC <23032356+SebastianMC@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:54:15 +0100 Subject: [PATCH] Removed the unfinished partial implementation of overrideTitle functionality --- src/custom-sort/custom-sort-types.ts | 1 - src/custom-sort/custom-sort.spec.ts | 93 ---------------------------- src/custom-sort/custom-sort.ts | 4 +- 3 files changed, 1 insertion(+), 97 deletions(-) diff --git a/src/custom-sort/custom-sort-types.ts b/src/custom-sort/custom-sort-types.ts index aa80327..9a18d89 100644 --- a/src/custom-sort/custom-sort-types.ts +++ b/src/custom-sort/custom-sort-types.ts @@ -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 diff --git a/src/custom-sort/custom-sort.spec.ts b/src/custom-sort/custom-sort.spec.ts index bfa1a83..999a749 100644 --- a/src/custom-sort/custom-sort.spec.ts +++ b/src/custom-sort/custom-sort.spec.ts @@ -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', () => { diff --git a/src/custom-sort/custom-sort.ts b/src/custom-sort/custom-sort.ts index 275f163..e9c6f48 100644 --- a/src/custom-sort/custom-sort.ts +++ b/src/custom-sort/custom-sort.ts @@ -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 } }