support home/end keys in branchlist (fixes #957)

This commit is contained in:
Stephan Dilly 2021-10-23 14:39:02 +02:00
parent dee97a77c4
commit 5c661be159
2 changed files with 15 additions and 1 deletions

View file

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- add `trace-libgit` feature to make git tracing optional [[@dm9pZCAq](https://github.com/dm9pZCAq)] ([#902](https://github.com/extrawurst/gitui/issues/902))
- support merging and rebasing remote branches ([#920](https://github.com/extrawurst/gitui/issues/920))
- add highlighting matches in fuzzy finder ([#893](https://github.com/extrawurst/gitui/issues/893))
- support `home` and `end` keys in branchlist ([#957](https://github.com/extrawurst/gitui/issues/957))
## [0.18] - 2021-10-11

View file

@ -226,6 +226,14 @@ impl Component for BranchListComponent {
return self
.move_selection(ScrollType::PageUp)
.map(Into::into);
} else if e == self.key_config.home {
return self
.move_selection(ScrollType::Home)
.map(Into::into);
} else if e == self.key_config.end {
return self
.move_selection(ScrollType::End)
.map(Into::into);
} else if e == self.key_config.tab_toggle {
self.local = !self.local;
self.update_branches()?;
@ -447,7 +455,12 @@ impl BranchListComponent {
ScrollType::PageUp => self
.selection
.saturating_sub(self.current_height.get()),
_ => self.selection,
ScrollType::Home => 0,
ScrollType::End => {
let num_branches: u16 =
self.branches.len().try_into()?;
num_branches.saturating_sub(1)
}
};
self.set_selection(new_selection)?;