Skip to content

Commit 5e62217

Browse files
author
Stephan Dilly
committed
fix commit msg details lockin (#780)
1 parent 3bdb1d3 commit 5e62217

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

src/components/branchlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl DrawableComponent for BranchListComponent {
5151
f: &mut Frame<B>,
5252
rect: Rect,
5353
) -> Result<()> {
54-
if self.visible {
54+
if self.is_visible() {
5555
const PERCENT_SIZE: Size = Size::new(80, 50);
5656
const MIN_SIZE: Size = Size::new(60, 20);
5757

src/components/revision_files.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,21 +218,22 @@ impl DrawableComponent for RevisionFilesComponent {
218218
f: &mut Frame<B>,
219219
area: Rect,
220220
) -> Result<()> {
221-
let chunks = Layout::default()
222-
.direction(Direction::Horizontal)
223-
.constraints(
224-
[
225-
Constraint::Percentage(40),
226-
Constraint::Percentage(60),
227-
]
228-
.as_ref(),
229-
)
230-
.split(area);
231-
232-
self.draw_tree(f, chunks[0]);
221+
if self.is_visible() {
222+
let chunks = Layout::default()
223+
.direction(Direction::Horizontal)
224+
.constraints(
225+
[
226+
Constraint::Percentage(40),
227+
Constraint::Percentage(60),
228+
]
229+
.as_ref(),
230+
)
231+
.split(area);
233232

234-
self.current_file.draw(f, chunks[1])?;
233+
self.draw_tree(f, chunks[0]);
235234

235+
self.current_file.draw(f, chunks[1])?;
236+
}
236237
Ok(())
237238
}
238239
}

src/components/utils/scroll_vertical.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ impl VerticalScroll {
6565
);
6666
self.top.set(new_top);
6767

68-
let new_max = selection_max.saturating_sub(visual_height);
69-
self.max_top.set(new_max);
68+
if visual_height == 0 {
69+
self.max_top.set(0);
70+
} else {
71+
let new_max = selection_max.saturating_sub(visual_height);
72+
self.max_top.set(new_max);
73+
}
7074

7175
new_top
7276
}
@@ -101,6 +105,9 @@ const fn calc_scroll_top(
101105
selection: usize,
102106
selection_max: usize,
103107
) -> usize {
108+
if height_in_lines == 0 {
109+
return 0;
110+
}
104111
if selection_max <= height_in_lines {
105112
return 0;
106113
}
@@ -123,4 +130,9 @@ mod tests {
123130
fn test_scroll_no_scroll_to_top() {
124131
assert_eq!(calc_scroll_top(1, 10, 4, 4), 0);
125132
}
133+
134+
#[test]
135+
fn test_scroll_zero_height() {
136+
assert_eq!(calc_scroll_top(4, 0, 4, 3), 0);
137+
}
126138
}

0 commit comments

Comments
 (0)