From cf2bfa383b7eeacd92714b409a5c15bfe08c23f3 Mon Sep 17 00:00:00 2001 From: Thomas SharedInbox Date: Sun, 7 Jun 2026 03:55:35 +0200 Subject: [PATCH] fix(search): fix _toFtsQuery to split on non-word chars instead of stripping The old implementation stripped non-word chars within tokens, causing 'searchable-{timestamp}' to become 'searchable{timestamp}*'. FTS5 tokenizes on hyphens so the merged token never matched. Fix: split on [^\w]+ so each FTS token is queried separately. Also add timeout: Timeout.none to chaos_monkey_test to prevent Dart's 30s default timeout from killing the 60s+ test. Co-Authored-By: Claude Sonnet 4.6 --- lib/data/repositories/email_repository_impl.dart | 4 +--- test/backend/chaos_monkey_test.dart | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/data/repositories/email_repository_impl.dart b/lib/data/repositories/email_repository_impl.dart index e238204..2cfbc93 100644 --- a/lib/data/repositories/email_repository_impl.dart +++ b/lib/data/repositories/email_repository_impl.dart @@ -2993,9 +2993,7 @@ class EmailRepositoryImpl implements EmailRepository { static String _toFtsQuery(String query) { final words = query .trim() - .split(RegExp(r'\s+')) - .where((w) => w.isNotEmpty) - .map((w) => w.replaceAll(RegExp(r'[^\w]'), '')) + .split(RegExp(r'[^\w]+')) .where((w) => w.isNotEmpty) .toList(); if (words.isEmpty) return ''; diff --git a/test/backend/chaos_monkey_test.dart b/test/backend/chaos_monkey_test.dart index f6715a4..58791c7 100644 --- a/test/backend/chaos_monkey_test.dart +++ b/test/backend/chaos_monkey_test.dart @@ -132,7 +132,7 @@ void main() { tearDown(() => db.close()); test('chaos monkey — random operations do not crash the repository', - () async { + timeout: Timeout.none, () async { final seedStr = _env('CHAOS_SEED'); final seed = seedStr.isEmpty ? DateTime.now().millisecondsSinceEpoch