Skip to content

Commit 9e64cb7

Browse files
committed
Fix always empty search results when using a backend that doesn't return highlights
This notably happens with Synapse on SQLite.
1 parent e596196 commit 9e64cb7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.d/8729.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix search results always being empty when using a backend that doesn't return highlights (e.g. Synapse on SQLite)

vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchResultController.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ class SearchResultController @Inject constructor(
148148
*/
149149
private fun setHighLightedText(text: String, highlights: List<String>): Spannable? {
150150
val wordToSpan: Spannable = SpannableString(text)
151+
152+
// Some backends don't return highlights at all (this is the case of Synapse with the SQLite storage).
153+
// In this case, don't attempt to filter based on the highlights, to avoid erasing all the results...
154+
if (highlights.isEmpty()) {
155+
return wordToSpan
156+
}
157+
151158
var found = false
152159
highlights.forEach { highlight ->
153160
var searchFromIndex = 0

0 commit comments

Comments
 (0)