Skip to content

Commit 06eb570

Browse files
committed
Fix scroll to bottom crash (#67)
1 parent 905650f commit 06eb570

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Scroll to root commit no longer crashes if root is a fork.
1013

1114

1215
## [0.1.18] - 2023-01-15

src/widgets/graph_view.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ impl StatefulWidget for GraphView<'_> {
166166
let move_to_end = if selected_index >= state.indices.len() - 1 {
167167
state.graph_lines.len() - 1
168168
} else {
169-
(state.indices[selected_index + 1] - 1).clamp(
170-
move_to_selected + SCROLL_MARGIN,
171-
state.graph_lines.len() - 1,
172-
)
169+
(state.indices[selected_index + 1] - 1)
170+
.max(move_to_selected + SCROLL_MARGIN)
171+
.min(state.graph_lines.len() - 1)
173172
};
174173
let move_to_start = move_to_selected.saturating_sub(SCROLL_MARGIN);
175174

0 commit comments

Comments
 (0)