Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8729.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix always empty search results when using a backend that doesn't return highlights (e.g. Synapse on SQLite)
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ class SearchResultController @Inject constructor(
*/
private fun setHighLightedText(text: String, highlights: List<String>): Spannable? {
val wordToSpan: Spannable = SpannableString(text)

// Some backends don't return highlights at all (this is the case of Synapse with the SQLite storage).
// In this case, don't attempt to filter based on the highlights, to avoid erasing all the results...
if (highlights.isEmpty()) {
return wordToSpan
}
Copy link
Member

@bmarty bmarty Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work, hence another possible fix would have been to just remove the var found below.
But it's maybe clearer like this.


var found = false
highlights.forEach { highlight ->
var searchFromIndex = 0
Expand Down