@@ -31,6 +31,9 @@ use crate::{
3131 utils:: unix_time_millis_to_datetime,
3232} ;
3333
34+ // Consider extracting this constant
35+ const SEARCH_HIGHLIGHT_COLOR : & str = "#fcdb03" ;
36+
3437live_design ! {
3538 use link:: theme:: * ;
3639 use link:: shaders:: * ;
@@ -289,7 +292,8 @@ fn apply_highlights(text: String, highlights: &[String]) -> String {
289292 & result,
290293 |caps : & regex:: Captures | {
291294 format ! (
292- "<span data-mx-bg-color=\" #fcdb03\" >{}</span>" ,
295+ "<span data-mx-bg-color=\" {}\" >{}</span>" ,
296+ SEARCH_HIGHLIGHT_COLOR ,
293297 & caps[ 0 ] . to_string( ) // Preserves original case
294298 )
295299 } ,
@@ -328,29 +332,29 @@ pub fn highlight_search_terms_in_message(message: &mut RoomMessageEventContent,
328332 }
329333
330334 match & mut message. msgtype {
331- MessageType :: Text ( text ) => {
332- apply_highlights_to_content ! ( text ) ;
335+ MessageType :: Text ( content ) => {
336+ apply_highlights_to_content ! ( content ) ;
333337 }
334- MessageType :: Notice ( text ) => {
335- apply_highlights_to_content ! ( text ) ;
338+ MessageType :: Notice ( content ) => {
339+ apply_highlights_to_content ! ( content ) ;
336340 }
337- MessageType :: Emote ( text ) => {
338- apply_highlights_to_content ! ( text ) ;
341+ MessageType :: Emote ( content ) => {
342+ apply_highlights_to_content ! ( content ) ;
339343 }
340- MessageType :: File ( text ) => {
341- apply_highlights_to_content ! ( text ) ;
344+ MessageType :: File ( content ) => {
345+ apply_highlights_to_content ! ( content ) ;
342346 }
343- MessageType :: Image ( text ) => {
344- apply_highlights_to_content ! ( text ) ;
347+ MessageType :: Image ( content ) => {
348+ apply_highlights_to_content ! ( content ) ;
345349 }
346- MessageType :: Video ( text ) => {
347- apply_highlights_to_content ! ( text ) ;
350+ MessageType :: Video ( content ) => {
351+ apply_highlights_to_content ! ( content ) ;
348352 }
349- MessageType :: Audio ( text ) => {
350- apply_highlights_to_content ! ( text ) ;
353+ MessageType :: Audio ( content ) => {
354+ apply_highlights_to_content ! ( content ) ;
351355 }
352- MessageType :: VerificationRequest ( text ) => {
353- apply_highlights_to_content ! ( text ) ;
356+ MessageType :: VerificationRequest ( content ) => {
357+ apply_highlights_to_content ! ( content ) ;
354358 }
355359 _ => { }
356360 }
0 commit comments