Repository navigation
Conversation
A search result now highlights the query's words in its participant names and subject, and a result whose body matched shows the words around the match in place of the start of the latest message, as Apple Mail does. FTS5's snippet() picks the window of the ThreadSearch body around the match, for the query's free-text terms phrased as LocalSearchQueryBackend phrases them. At most four words are kept before the first match, so a narrow row doesn't cut the match off. One prefix highlighter marks the words in excerpts, subjects and participants: "wall" highlights "Wall" in "Wallpaper", ignoring case and diacritics. subject: terms apply to subjects only, from: and to: terms to participants only, and terms under a NOT are never highlighted. A body found only through Porter stemming keeps its plain snippet. The search subscription hands the thread list a single highlighter, set on each result as __searchMatch. The highlight colors are theme variables (@list-search-match-bg/-color, from @text-color-search-match), overridden in ui-dark with a dark yellow.
|
Thanks Mark, this is a great improvement. Showing why a result matched makes search feel much better, and we'd love to have it. Scoping it to search results only, carrying the match on the cloned threads like Two changes we'd like before merging, and a few optional ones: Required1. Don't re-query excerpts on every list emission, and don't hold the list until they load. Excerpts don't change while the highlighter lives, so please:
2. Use FTS5's own match markers in
Optional
Please keep the scope to the two required items plus whatever optional ones you want; no need to expand beyond that. Thanks again, really nice work! |
… core
Each thread's excerpt is loaded once for the life of the thread list's data
source, and results are emitted without waiting for the excerpt query, then
again with excerpts once it finishes.
snippet() marks what the index matched, so a body found through Porter
stemming ("invoicing" for "invoice") is highlighted too; a literal match is
still trimmed to the typed prefix.
The highlighter lives in services/search and is exported through
mailspring-exports. The search perspective provides it through
MailboxPerspective.searchHighlighter(), and ThreadListStore hands it to
ThreadListDataSource.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks Ben! All addressed: 1. Excerpt queries. Excerpts are now cached per thread for the life of the data source. Each list update only queries threads that haven't been loaded or requested yet, and a request that's still running is shared, not sent again. Results show up right away with the plain snippet, then update once the excerpts arrive. 2. FTS5 markers. Where the code lives. The highlighter and its spec moved to Dark themes. I left these alone. ui-taiga and ui-darkside draw the thread list on white (only their sidebars are dark), so the yellow looks the same as in ui-light. |
A search result whose body matched now shows the words around the match in place of the start of the latest messages. FTS5's snippet() cuts the passage from the ThreadSearch body column for the query's free-text terms, and the mark is trimmed to the typed prefix, so "wall" highlights "Wall" in "Wallpaper". Matches are highlighted in yellow, or a dark yellow in themes with light text.