Skip to content

Commit 0f338b8

Browse files
committed
fix: the status tree page-down action overflows the tree length
1 parent bff6fba commit 0f338b8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: src/components/utils/statustree.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,18 @@ impl StatusTree {
308308
new_index = new_index.saturating_add(1);
309309
}
310310

311-
if self.is_visible_index(new_index) {
312-
count += 1;
313-
}
314-
315311
if count == self.window_height.get().unwrap_or(0) {
316312
break;
317313
}
318314

319-
if new_index == 0 || new_index == self.tree.len() - 1 {
315+
if new_index == 0 || new_index >= self.tree.len() - 1 {
316+
new_index = cmp::min(new_index, self.tree.len() - 1);
320317
break;
321318
}
319+
320+
if self.is_visible_index(new_index) {
321+
count += 1;
322+
}
322323
}
323324

324325
SelectionChange::new(new_index, false)

0 commit comments

Comments
 (0)