diff --git a/src/main.test.ts b/src/main.test.ts index 6676c0f7..e1fcf210 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -104,7 +104,7 @@ describe('main entrypoint', () => { rootOptions().onCaughtError?.(error, { componentStack: '\n in App' }) expect(mocks.sentryHandler).toHaveBeenCalledWith(error, { componentStack: '\n in App' }) - }, 20_000) + }, 60_000) it('normalizes missing React component stacks before handing errors to Sentry', async () => { await importEntrypoint() diff --git a/src/utils/noteListHelpers.test.ts b/src/utils/noteListHelpers.test.ts index a9af0fed..b8127dd1 100644 --- a/src/utils/noteListHelpers.test.ts +++ b/src/utils/noteListHelpers.test.ts @@ -68,11 +68,24 @@ describe('filterEntries', () => { makeEntry({ path: '/vault/note/real-note.md', title: 'Real Note', isA: 'Note' }), makeEntry({ path: '/vault/attachments/reference.md', title: 'Attachment Markdown', isA: 'Note' }), makeEntry({ path: '/vault/attachments/nested/diagram.md', title: 'Nested Attachment Markdown', isA: 'Note' }), + makeEntry({ path: 'C:\\Users\\luca\\Vault\\attachments\\windows.md', title: 'Windows Attachment Markdown', isA: 'Note' }), ] const result = filterEntries(entries, allSelection, 'open') expect(result.map((entry) => entry.title)).toEqual(['Real Note']) }) + + it('matches slash-based folder selections against Windows entry paths', () => { + const entries = [ + makeEntry({ path: 'C:\\Users\\luca\\Vault\\Client Work\\Alpha.md', title: 'Alpha' }), + makeEntry({ path: 'C:\\Users\\luca\\Vault\\Client Work\\Nested\\Beta.md', title: 'Beta' }), + makeEntry({ path: 'C:\\Users\\luca\\Vault\\Client Work Archive\\Old.md', title: 'Archive' }), + makeEntry({ path: 'C:\\Users\\luca\\Vault\\客户\\计划.md', title: 'Unicode' }), + ] + + expect(filterEntries(entries, { kind: 'folder', path: 'Client Work' }).map((entry) => entry.title)).toEqual(['Alpha', 'Beta']) + expect(filterEntries(entries, { kind: 'folder', path: '客户' }).map((entry) => entry.title)).toEqual(['Unicode']) + }) }) describe('countByFilter', () => { diff --git a/src/utils/noteListHelpers.ts b/src/utils/noteListHelpers.ts index 70900771..5103db9c 100644 --- a/src/utils/noteListHelpers.ts +++ b/src/utils/noteListHelpers.ts @@ -397,8 +397,14 @@ function applySubFilter(entries: VaultEntry[], subFilter: NoteListFilter): Vault } function isInFolder(entryPath: string, folderRelPath: string): boolean { - const needle = '/' + folderRelPath + '/' - return entryPath.includes(needle) || entryPath.startsWith(folderRelPath + '/') + const folderPath = normalizeFolderPath(folderRelPath) + if (!folderPath) return false + const normalizedEntryPath = normalizeFolderPath(entryPath) + return normalizedEntryPath.includes(`/${folderPath}/`) || normalizedEntryPath.startsWith(`${folderPath}/`) +} + +function normalizeFolderPath(path: string): string { + return path.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '') } export function isAllNotesEntry(entry: VaultEntry): boolean {