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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas SharedInbox
2026-06-07 03:53:46 +02:00
co-authored by Claude Sonnet 4.6
parent 6ad8cbf600
commit 98f20a2191
@@ -2992,9 +2992,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 '';