fix: mouse wheel scroll now moves cursor in history browser#40
Merged
Conversation
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]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
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
TextScrollStatestruct - Introduced
with_alternate_screenhelper 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
with_alternate_screenhelper with RAII drop guard for panic-safe terminal state cleanupTextScrollStatestruct to deduplicate text scroll animation logic between help browser and history browser