Skip to content

Commit fea917c

Browse files
committed
removed unnecessary update_rows() call and minor refactoring
1 parent 948e16e commit fea917c

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/list.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()>
6767
}
6868

6969
match key.code {
70-
KeyCode::Char('q') => {
71-
return Ok(());
72-
}
70+
KeyCode::Char('q') => return Ok(()),
7371
KeyCode::Down | KeyCode::Char('j') => list_state.select_next(),
7472
KeyCode::Up | KeyCode::Char('k') => list_state.select_previous(),
7573
KeyCode::Home | KeyCode::Char('g') => list_state.select_first(),
@@ -102,7 +100,7 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()>
102100
return Ok(());
103101
}
104102
}
105-
KeyCode::Char('s') | KeyCode::Char('/') => {
103+
KeyCode::Char('s' | '/') => {
106104
list_state.message.push_str("search:|");
107105
is_searching = true;
108106
}

src/list/state.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,23 +374,21 @@ impl<'a> ListState<'a> {
374374
}
375375
})
376376
.enumerate()
377-
.find_map(|(i, s)| {
378-
if s.name.contains(self.search_query.as_str()) {
379-
Some(i)
377+
.find_map(|(idx, exercise)| {
378+
if exercise.name.contains(self.search_query.as_str()) {
379+
Some(idx)
380380
} else {
381381
None
382382
}
383383
});
384384

385385
match idx {
386-
Some(i) => {
387-
let exercise_ind = i;
386+
Some(x) => {
387+
let exercise_ind = x;
388388
self.scroll_state.set_selected(exercise_ind);
389-
self.update_rows();
390389
}
391390
None => {
392-
let msg = String::from("[NOT FOUND]") + &self.message.clone();
393-
self.message.clear();
391+
let msg = String::from(" (not found)");
394392
self.message.push_str(&msg);
395393
}
396394
}

0 commit comments

Comments
 (0)