Skip to content

Commit 1b8b58a

Browse files
author
Stephan Dilly
authored
fix missing paging support in branch list (#539)
closes #519
1 parent e3bb51b commit 1b8b58a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
![push](assets/char_count.gif)
1616

1717
### Fixed
18+
- support missing pageUp/down support in branchlist ([#519](https://github.com/extrawurst/gitui/issues/519))
1819
- don't hide branch name while in commit dialog ([#529](https://github.com/extrawurst/gitui/issues/529))
1920
- don't discard commit message without confirmation ([#530](https://github.com/extrawurst/gitui/issues/530))
2021
- compilation broken on freebsd ([#461](https://github.com/extrawurst/gitui/issues/461))

src/components/select_branch.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ use asyncgit::{
1616
CWD,
1717
};
1818
use crossterm::event::Event;
19-
use std::{cell::Cell, convert::TryInto};
19+
use std::{
20+
cell::Cell,
21+
convert::{TryFrom, TryInto},
22+
};
2023
use tui::{
2124
backend::Backend,
2225
layout::{Alignment, Rect},
@@ -35,6 +38,7 @@ pub struct SelectBranchComponent {
3538
visible: bool,
3639
selection: u16,
3740
scroll_top: Cell<usize>,
41+
current_height: Cell<u16>,
3842
queue: Queue,
3943
theme: SharedTheme,
4044
key_config: SharedKeyConfig,
@@ -92,6 +96,8 @@ impl DrawableComponent for SelectBranchComponent {
9296
self.branch_names.len(),
9397
self.scroll_top.get(),
9498
);
99+
100+
self.current_height.set(u16::try_from(height_in_lines)?);
95101
}
96102

97103
Ok(())
@@ -155,6 +161,10 @@ impl Component for SelectBranchComponent {
155161
return self.move_selection(ScrollType::Up);
156162
} else if e == self.key_config.move_up {
157163
return self.move_selection(ScrollType::Down);
164+
} else if e == self.key_config.page_down {
165+
return self.move_selection(ScrollType::PageDown);
166+
} else if e == self.key_config.page_up {
167+
return self.move_selection(ScrollType::PageUp);
158168
} else if e == self.key_config.enter {
159169
if let Err(e) = self.switch_to_selected_branch() {
160170
log::error!("switch branch error: {}", e);
@@ -232,6 +242,7 @@ impl SelectBranchComponent {
232242
queue,
233243
theme,
234244
key_config,
245+
current_height: Cell::new(0),
235246
}
236247
}
237248
/// Get all the names of the branches in the repo
@@ -273,6 +284,12 @@ impl SelectBranchComponent {
273284
let mut new_selection = match scroll {
274285
ScrollType::Up => self.selection.saturating_add(1),
275286
ScrollType::Down => self.selection.saturating_sub(1),
287+
ScrollType::PageDown => self
288+
.selection
289+
.saturating_add(self.current_height.get()),
290+
ScrollType::PageUp => self
291+
.selection
292+
.saturating_sub(self.current_height.get()),
276293
_ => self.selection,
277294
};
278295

0 commit comments

Comments
 (0)