mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
pager: Simplify some code
This commit is contained in:
parent
31c2eb3f3c
commit
3d1e8a6106
1 changed files with 8 additions and 15 deletions
21
src/pager.rs
21
src/pager.rs
|
@ -636,17 +636,11 @@ impl Pager {
|
||||||
None => {
|
None => {
|
||||||
// Handle the case of nothing selected yet.
|
// Handle the case of nothing selected yet.
|
||||||
match direction {
|
match direction {
|
||||||
SelectionMotion::South
|
SelectionMotion::South | SelectionMotion::PageSouth | SelectionMotion::Next => {
|
||||||
| SelectionMotion::PageSouth
|
self.selected_completion_idx = Some(0)
|
||||||
| SelectionMotion::Next
|
|
||||||
| SelectionMotion::North
|
|
||||||
| SelectionMotion::Prev => {
|
|
||||||
// These directions do something sane.
|
|
||||||
if matches!(direction, SelectionMotion::Prev | SelectionMotion::North) {
|
|
||||||
self.selected_completion_idx = Some(self.completion_infos.len() - 1);
|
|
||||||
} else {
|
|
||||||
self.selected_completion_idx = Some(0);
|
|
||||||
}
|
}
|
||||||
|
SelectionMotion::North | SelectionMotion::Prev => {
|
||||||
|
self.selected_completion_idx = Some(self.completion_infos.len() - 1)
|
||||||
}
|
}
|
||||||
SelectionMotion::East
|
SelectionMotion::East
|
||||||
| SelectionMotion::West
|
| SelectionMotion::West
|
||||||
|
@ -967,10 +961,9 @@ impl Pager {
|
||||||
// Updates the completions list per the filter.
|
// Updates the completions list per the filter.
|
||||||
pub fn refilter_completions(&mut self) {
|
pub fn refilter_completions(&mut self) {
|
||||||
self.completion_infos.clear();
|
self.completion_infos.clear();
|
||||||
for i in 0..self.unfiltered_completion_infos.len() {
|
for comp in &self.unfiltered_completion_infos {
|
||||||
if self.completion_info_passes_filter(&self.unfiltered_completion_infos[i]) {
|
if self.completion_info_passes_filter(comp) {
|
||||||
self.completion_infos
|
self.completion_infos.push(comp.clone());
|
||||||
.push(self.unfiltered_completion_infos[i].clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue