diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index 1fe7bd08..e5fe6ce2 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -451,8 +451,26 @@ module.exports = { } } }).then(function(data) { + // for debugging: + // data.search_categories.room_events.highlights = ["hello", "everybody"]; + + var highlights; + if (data.search_categories.room_events.highlights && + data.search_categories.room_events.highlights.length > 0) + { + // postgres on synapse returns us precise details of the + // strings which actually got matched for highlighting. + // for overlapping highlights, favour longer (more specific) terms first + highlights = data.search_categories.room_events.highlights + .sort(function(a, b) { b.length - a.length }); + } + else { + // sqlite doesn't, so just highlight the literal search term + highlights = [ term ]; + } + self.setState({ - searchTerm: term, + highlights: highlights, searchResults: data, }); }, function(error) { @@ -490,7 +508,7 @@ module.exports = { } } if (EventTile.haveTileForEvent(mxEv)) { - ret.push(