fix commit msg details lockin (#780)

This commit is contained in:
Stephan Dilly 2021-06-10 09:56:20 +02:00
parent 3bdb1d3a1a
commit 5e62217928
3 changed files with 29 additions and 16 deletions

View File

@ -51,7 +51,7 @@ impl DrawableComponent for BranchListComponent {
f: &mut Frame<B>,
rect: Rect,
) -> Result<()> {
if self.visible {
if self.is_visible() {
const PERCENT_SIZE: Size = Size::new(80, 50);
const MIN_SIZE: Size = Size::new(60, 20);

View File

@ -218,21 +218,22 @@ impl DrawableComponent for RevisionFilesComponent {
f: &mut Frame<B>,
area: Rect,
) -> Result<()> {
let chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Percentage(40),
Constraint::Percentage(60),
]
.as_ref(),
)
.split(area);
if self.is_visible() {
let chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Percentage(40),
Constraint::Percentage(60),
]
.as_ref(),
)
.split(area);
self.draw_tree(f, chunks[0]);
self.current_file.draw(f, chunks[1])?;
self.draw_tree(f, chunks[0]);
self.current_file.draw(f, chunks[1])?;
}
Ok(())
}
}

View File

@ -65,8 +65,12 @@ impl VerticalScroll {
);
self.top.set(new_top);
let new_max = selection_max.saturating_sub(visual_height);
self.max_top.set(new_max);
if visual_height == 0 {
self.max_top.set(0);
} else {
let new_max = selection_max.saturating_sub(visual_height);
self.max_top.set(new_max);
}
new_top
}
@ -101,6 +105,9 @@ const fn calc_scroll_top(
selection: usize,
selection_max: usize,
) -> usize {
if height_in_lines == 0 {
return 0;
}
if selection_max <= height_in_lines {
return 0;
}
@ -123,4 +130,9 @@ mod tests {
fn test_scroll_no_scroll_to_top() {
assert_eq!(calc_scroll_top(1, 10, 4, 4), 0);
}
#[test]
fn test_scroll_zero_height() {
assert_eq!(calc_scroll_top(4, 0, 4, 3), 0);
}
}