Skip to content

Commit

Permalink
Fix always empty search results when using a backend that doesn't ret…
Browse files Browse the repository at this point in the history
…urn highlights

This notably happens with Synapse on SQLite.
  • Loading branch information
mlaily committed Jan 7, 2024
1 parent e596196 commit 9e64cb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/8729.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix search results always being empty 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
}

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

0 comments on commit 9e64cb7

Please sign in to comment.