@@ -105,6 +105,28 @@ impl<'a> ListState<'a> {
105105 ) ;
106106 }
107107
108+ fn draw_exericse_name ( & self , writer : & mut MaxLenWriter , exercise : & Exercise ) -> io:: Result < ( ) > {
109+ if !self . search_query . is_empty ( ) {
110+ if let Some ( ( pre_highlight, highlight, post_highlight) ) = exercise
111+ . name
112+ . find ( & self . search_query )
113+ . and_then ( |ind| exercise. name . split_at_checked ( ind) )
114+ . and_then ( |( pre_highlight, rest) | {
115+ rest. split_at_checked ( self . search_query . len ( ) )
116+ . map ( |x| ( pre_highlight, x. 0 , x. 1 ) )
117+ } )
118+ {
119+ writer. write_str ( pre_highlight) ?;
120+ writer. stdout . queue ( SetForegroundColor ( Color :: Magenta ) ) ?;
121+ writer. write_str ( highlight) ?;
122+ writer. stdout . queue ( ResetColor ) ?;
123+ return writer. write_str ( post_highlight) ;
124+ }
125+ }
126+
127+ writer. write_str ( exercise. name )
128+ }
129+
108130 fn draw_rows (
109131 & self ,
110132 stdout : & mut StdoutLock ,
@@ -147,10 +169,10 @@ impl<'a> ListState<'a> {
147169 writer. stdout . queue ( SetForegroundColor ( Color :: Yellow ) ) ?;
148170 writer. write_ascii ( b"PENDING " ) ?;
149171 }
150-
151172 writer. stdout . queue ( SetForegroundColor ( Color :: Reset ) ) ?;
152173
153- writer. write_str ( exercise. name ) ?;
174+ self . draw_exericse_name ( & mut writer, exercise) ?;
175+
154176 writer. write_ascii ( & self . name_col_padding [ exercise. name . len ( ) ..] ) ?;
155177
156178 // The list links aren't shown correctly in VS Code on Windows.
0 commit comments