@@ -105,6 +105,28 @@ impl<'a> ListState<'a> {
105
105
) ;
106
106
}
107
107
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
+
108
130
fn draw_rows (
109
131
& self ,
110
132
stdout : & mut StdoutLock ,
@@ -147,10 +169,10 @@ impl<'a> ListState<'a> {
147
169
writer. stdout . queue ( SetForegroundColor ( Color :: Yellow ) ) ?;
148
170
writer. write_ascii ( b"PENDING " ) ?;
149
171
}
150
-
151
172
writer. stdout . queue ( SetForegroundColor ( Color :: Reset ) ) ?;
152
173
153
- writer. write_str ( exercise. name ) ?;
174
+ self . draw_exericse_name ( & mut writer, exercise) ?;
175
+
154
176
writer. write_ascii ( & self . name_col_padding [ exercise. name . len ( ) ..] ) ?;
155
177
156
178
// The list links aren't shown correctly in VS Code on Windows.
0 commit comments