Skip to content

Commit 3931fc1

Browse files
author
Paulo Remoli
committed
fix issue with mouse scroll not reaching the bottom
1 parent def9d2c commit 3931fc1

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to logana will be documented in this file.
55

66
## [Unreleased]
77

8+
### Fixed
9+
- Fixed mouse scroll in tail mode: scroll up pauses following, scroll down to the bottom resumes it.
10+
811
## [0.5.0] - 2026-03-29
912
### Added
1013
- Mouse support

src/ui/app.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,19 @@ impl App {
564564
.filter
565565
.visible_indices
566566
.len()
567-
.saturating_sub(tab.scroll.visible_height);
567+
.saturating_sub(1);
568568
if delta < 0 {
569+
tab.stream.tail_mode = false;
569570
tab.scroll.scroll_offset = tab
570571
.scroll
571572
.scroll_offset
572573
.saturating_sub(delta.unsigned_abs() as usize);
573574
} else {
574-
tab.scroll.scroll_offset = (tab.scroll.scroll_offset + delta as usize).min(max_scroll);
575+
let new_offset = (tab.scroll.scroll_offset + delta as usize).min(max_scroll);
576+
tab.scroll.scroll_offset = new_offset;
577+
if new_offset >= max_scroll {
578+
tab.stream.tail_mode = true;
579+
}
575580
}
576581
if matches!(
577582
tab.interaction.mode.render_state(),
@@ -2609,7 +2614,40 @@ mod tests {
26092614
let mut app = app_with_areas(15, 10, area, None).await;
26102615
app.tabs[0].scroll.scroll_offset = 0;
26112616
app.mouse_scroll(100);
2612-
assert_eq!(app.tabs[0].scroll.scroll_offset, 5);
2617+
// max_scroll = 15 - 1 = 14 (scroll_offset is the focused/last-visible line)
2618+
assert_eq!(app.tabs[0].scroll.scroll_offset, 14);
2619+
}
2620+
2621+
#[tokio::test]
2622+
async fn test_mouse_scroll_up_disables_tail_mode() {
2623+
let area = Rect {
2624+
x: 0,
2625+
y: 0,
2626+
width: 80,
2627+
height: 10,
2628+
};
2629+
let mut app = app_with_areas(20, 10, area, None).await;
2630+
app.tabs[0].stream.tail_mode = true;
2631+
app.tabs[0].scroll.scroll_offset = 10;
2632+
app.mouse_scroll(-5);
2633+
assert!(!app.tabs[0].stream.tail_mode, "scroll up should disable tail mode");
2634+
}
2635+
2636+
#[tokio::test]
2637+
async fn test_mouse_scroll_down_to_bottom_reenables_tail_mode() {
2638+
let area = Rect {
2639+
x: 0,
2640+
y: 0,
2641+
width: 80,
2642+
height: 10,
2643+
};
2644+
// 20 lines, max_scroll = 20 - 1 = 19 (scroll_offset is the focused/last-visible line)
2645+
let mut app = app_with_areas(20, 10, area, None).await;
2646+
app.tabs[0].stream.tail_mode = false;
2647+
app.tabs[0].scroll.scroll_offset = 0;
2648+
app.mouse_scroll(100); // large delta → clamps to max_scroll=19
2649+
assert!(app.tabs[0].stream.tail_mode, "reaching bottom should re-enable tail mode");
2650+
assert_eq!(app.tabs[0].scroll.scroll_offset, 19);
26132651
}
26142652

26152653
#[tokio::test]

0 commit comments

Comments
 (0)