Skip to content

Commit 69d09c4

Browse files
author
Stephan Dilly
committed
support home/end keys in branchlist (fixes #957)
1 parent c455f82 commit 69d09c4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

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

1516
## [0.18] - 2021-10-11
1617

src/components/branchlist.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ impl Component for BranchListComponent {
226226
return self
227227
.move_selection(ScrollType::PageUp)
228228
.map(Into::into);
229+
} else if e == self.key_config.home {
230+
return self
231+
.move_selection(ScrollType::Home)
232+
.map(Into::into);
233+
} else if e == self.key_config.end {
234+
return self
235+
.move_selection(ScrollType::End)
236+
.map(Into::into);
229237
} else if e == self.key_config.tab_toggle {
230238
self.local = !self.local;
231239
self.update_branches()?;
@@ -447,7 +455,12 @@ impl BranchListComponent {
447455
ScrollType::PageUp => self
448456
.selection
449457
.saturating_sub(self.current_height.get()),
450-
_ => self.selection,
458+
ScrollType::Home => 0,
459+
ScrollType::End => {
460+
let num_branches: u16 =
461+
self.branches.len().try_into()?;
462+
num_branches.saturating_sub(1)
463+
}
451464
};
452465

453466
self.set_selection(new_selection)?;

0 commit comments

Comments
 (0)