Skip to content

Commit 3d1e8a6

Browse files
committed
pager: Simplify some code
1 parent 31c2eb3 commit 3d1e8a6

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/pager.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -636,17 +636,11 @@ impl Pager {
636636
None => {
637637
// Handle the case of nothing selected yet.
638638
match direction {
639-
SelectionMotion::South
640-
| SelectionMotion::PageSouth
641-
| SelectionMotion::Next
642-
| SelectionMotion::North
643-
| SelectionMotion::Prev => {
644-
// These directions do something sane.
645-
if matches!(direction, SelectionMotion::Prev | SelectionMotion::North) {
646-
self.selected_completion_idx = Some(self.completion_infos.len() - 1);
647-
} else {
648-
self.selected_completion_idx = Some(0);
649-
}
639+
SelectionMotion::South | SelectionMotion::PageSouth | SelectionMotion::Next => {
640+
self.selected_completion_idx = Some(0)
641+
}
642+
SelectionMotion::North | SelectionMotion::Prev => {
643+
self.selected_completion_idx = Some(self.completion_infos.len() - 1)
650644
}
651645
SelectionMotion::East
652646
| SelectionMotion::West
@@ -967,10 +961,9 @@ impl Pager {
967961
// Updates the completions list per the filter.
968962
pub fn refilter_completions(&mut self) {
969963
self.completion_infos.clear();
970-
for i in 0..self.unfiltered_completion_infos.len() {
971-
if self.completion_info_passes_filter(&self.unfiltered_completion_infos[i]) {
972-
self.completion_infos
973-
.push(self.unfiltered_completion_infos[i].clone());
964+
for comp in &self.unfiltered_completion_infos {
965+
if self.completion_info_passes_filter(comp) {
966+
self.completion_infos.push(comp.clone());
974967
}
975968
}
976969
}

0 commit comments

Comments
 (0)