From 7eb72894720c180fa9b01e28a5c5d95fee1fc710 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 13:52:07 +0100 Subject: [PATCH] fix: stop a settings search for "recover" from offering Reading --- src/lib/__tests__/settings-search-recovery.test.ts | 10 ++++++++++ src/lib/settings-search.ts | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/__tests__/settings-search-recovery.test.ts b/src/lib/__tests__/settings-search-recovery.test.ts index 852677e5..d1d4e6e8 100644 --- a/src/lib/__tests__/settings-search-recovery.test.ts +++ b/src/lib/__tests__/settings-search-recovery.test.ts @@ -22,4 +22,14 @@ describe('settings search for Delegates and Recover deleted items', () => { expect(finds('recovery', 'Recover deleted items', 'emptied')).toBe(true); expect(finds('recovery', 'Recover deleted items', 'colleague')).toBe(false); }); + + // The delete action's warning ("... cannot be recovered") put Reading in + // the results, and it has nothing about recovering. + it('finds "recover" in Recover deleted items only, not in Reading', () => { + const q = normalizeSettingsQuery('recover'); + expect(tabMatchesQuery(index, 'recovery', 'Recover deleted items', q)).toBe(true); + expect(tabMatchesQuery(index, 'reading', 'Reading', q)).toBe(false); + // Reading is still found by the delete action itself. + expect(tabMatchesQuery(index, 'reading', 'Reading', normalizeSettingsQuery('delete action'))).toBe(true); + }); }); diff --git a/src/lib/settings-search.ts b/src/lib/settings-search.ts index ccf96778..06948ffc 100644 --- a/src/lib/settings-search.ts +++ b/src/lib/settings-search.ts @@ -323,6 +323,12 @@ export function getByPath(obj: unknown, path: string): unknown { return cur; } +// Leaves that say what a setting does once picked, not what it is: the +// delete action's warning ("... cannot be recovered") made a search for +// "recover" offer Reading, which has nothing about recovering. The webmail +// indexes labels only. +const UNSEARCHED_LEAVES = new Set(['warning']); + // Every string leaf key below `path`. export function collectStringKeys(node: unknown, path: string, sink: string[]): void { if (typeof node === 'string') { @@ -331,6 +337,7 @@ export function collectStringKeys(node: unknown, path: string, sink: string[]): } if (!node || typeof node !== 'object' || Array.isArray(node)) return; for (const [key, value] of Object.entries(node as Dictionary)) { + if (typeof value === 'string' && UNSEARCHED_LEAVES.has(key)) continue; collectStringKeys(value, `${path}.${key}`, sink); } }