File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -356,16 +356,17 @@ impl<'a> ListState<'a> {
356
356
return ;
357
357
}
358
358
359
- let ind = self
360
- . app_state
361
- . exercises ( )
362
- . iter ( )
363
- . filter ( |exercise| match self . filter {
364
- Filter :: None => true ,
365
- Filter :: Done => exercise. done ,
366
- Filter :: Pending => !exercise. done ,
367
- } )
368
- . position ( |exercise| exercise. name . contains ( self . search_query . as_str ( ) ) ) ;
359
+ let is_search_result = |exercise : & Exercise | exercise. name . contains ( & self . search_query ) ;
360
+ let mut iter = self . app_state . exercises ( ) . iter ( ) ;
361
+ let ind = match self . filter {
362
+ Filter :: None => iter. position ( is_search_result) ,
363
+ Filter :: Done => iter
364
+ . filter ( |exercise| exercise. done )
365
+ . position ( is_search_result) ,
366
+ Filter :: Pending => iter
367
+ . filter ( |exercise| !exercise. done )
368
+ . position ( is_search_result) ,
369
+ } ;
369
370
370
371
match ind {
371
372
Some ( exercise_ind) => self . scroll_state . set_selected ( exercise_ind) ,
You can’t perform that action at this time.
0 commit comments