Skip to content

fix: mouse wheel scroll now moves cursor in history browser#40

Merged
eitsupi merged 6 commits intomainfrom
fix/mouse-wheel-history-browser
Feb 3, 2026
Merged

fix: mouse wheel scroll now moves cursor in history browser#40
eitsupi merged 6 commits intomainfrom
fix/mouse-wheel-history-browser

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 3, 2026

Summary

  • Fix mouse wheel scrolling in history browser to move the cursor (selection) instead of just the viewport, matching help browser behavior
  • Extract shared with_alternate_screen helper with RAII drop guard for panic-safe terminal state cleanup
  • Extract TextScrollState struct to deduplicate text scroll animation logic between help browser and history browser

eitsupi and others added 4 commits February 3, 2026 14:26
Mouse wheel scrolling was moving the viewport (scroll_offset) instead of
the cursor/selection. When all entries fit on screen, this had no visible
effect since max_scroll was 0. Changed to use move_cursor_up/down like
the help browser, so mouse wheel always moves the highlighted item.

Also added debug logging for all events (matching help.rs pattern).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ation)

- Add with_alternate_screen() to eliminate duplicated terminal
  setup/teardown across mod.rs, help.rs, and history_browser.rs
- Add TextScrollState struct to consolidate identical text scroll
  animation logic from help.rs and history_browser.rs
- Centralize SCROLL_INTERVAL_MS and SCROLL_PAUSE_MS constants
- Remove unused imports (Instant, Enter/LeaveAlternateScreen, etc.)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Consistent with help.rs and history_browser.rs patterns. Prevents
potential missed redraws at scroll boundaries.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace manual teardown sequence in `with_alternate_screen` with an
RAII drop guard (`AlternateScreenGuard`). This ensures the terminal
is restored to its normal state even if the closure panics, making
the "guaranteed teardown" promise in the doc comment accurate.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where mouse wheel scrolling in the history browser only scrolled the view without moving the cursor, potentially leaving the selected item off-screen. It also includes a refactoring to extract common terminal management and text scrolling animation code.

Changes:

  • Fixed mouse wheel scroll in history browser to move the cursor (selection) instead of just the view offset
  • Extracted and centralized text scroll animation logic into a reusable TextScrollState struct
  • Introduced with_alternate_screen helper with RAII guard for safer terminal state management

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/arf-console/src/pager/mod.rs Added TextScrollState for text animation, with_alternate_screen with RAII guard for terminal management, and extracted constants; simplified mouse scroll handling
crates/arf-console/src/pager/history_browser.rs Fixed mouse wheel scroll to move cursor via move_cursor_up/down(), adopted TextScrollState for text animation, used with_alternate_screen for terminal setup/cleanup, added debug logging
crates/arf-console/src/pager/help.rs Adopted TextScrollState for text animation and with_alternate_screen for terminal management; removed duplicate constants and code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Move AlternateScreenGuard creation to right after EnterAlternateScreen
so that partial setup failures (e.g. EnableMouseCapture or
enable_raw_mode failing) still get cleaned up via the drop guard.

Also change history_browser event logging from debug to trace level,
since per-event logging in the event loop is too verbose for debug.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi merged commit ac1dc04 into main Feb 3, 2026
10 checks passed
@eitsupi eitsupi deleted the fix/mouse-wheel-history-browser branch February 3, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants