fix(inventory): make wheel scrolling stop when the user does - #660
Open
naxty wants to merge 2 commits into
Open
Conversation
Scrolling the inventory list with the mouse wheel kept moving well after the wheel stopped, and the further the list travelled the worse it got. Three separate causes, all on the per-event path: - Every navigation key re-ran the whole filter -> sort -> truncate -> style pipeline over the capped row set, and the render path re-ran the filter and sort twice more per frame, for a result that a cursor move cannot change. Navigation no longer re-syncs, and the view path counts filtered rows without sorting them. - Without mouse tracking a terminal in the alternate screen turns one wheel notch into several arrow keys, so a notch cost several full frames. The inventory TUI now enables tracking and sizes the step itself; other TUIs are unchanged, and FORMAE_TUI_NO_MOUSE opts out for anyone who would rather keep click-drag text selection. - Bubbletea renders after every message, so a fast flick still queued more frames than the renderer could retire. Wheel travel now accumulates and a settle tick applies the total in one move and one repaint; mid-burst frames reuse the last paint. Per queued notch: 8.45ms -> 0.011ms, with one 2.2ms settle per burst. While fixing the render path, two display bugs surfaced that scrolling made easy to hit: resizing the table rebuilt the wrapped table's rows and reset its scroll offset while keeping the cursor, so the selected row left the screen after roughly one screenful of travel (the render path resizes on every frame); and per-cell styling was applied by absolute row index to a window of rendered lines, so it landed on the wrong rows once scrolled. Same-size resizes are now a no-op, only width changes reproject, and cell styling aligns to the rendered window.
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
Wheel-scrolling
formae inventory resourceskept moving long after the wheel stopped. Three causes, all on the per-event path:FORMAE_TUI_NO_MOUSE=1opts out for anyone who would rather keep click-drag text selection (with tracking on, selection needs shift held).Per queued notch: 8.45 ms → 0.011 ms, plus one 2.2 ms settle per burst (1000 resources, benchmarks included).
Two display bugs surfaced while fixing the render path — both pre-existing, both made trivial to hit by wheel scrolling:
Covered by new tests for wheel coalescing, frame reuse, scroll-follow, and the filtered-count equality that the split view path relies on. Golden renders are unchanged.