fix: scroll settings list to keep selection in view#294
Merged
Conversation
The settings list was rendered statelessly, so the viewport never scrolled and items below the fold were unreachable on shorter terminals. Render it with a ListState seeded from the selected index, matching every other list screen, so ratatui scrolls to keep the selection visible.
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
The Settings screen list could not be scrolled past what initially fit on screen. Pressing Down moved the highlight through the visible rows, but the viewport never scrolled to reveal items below the fold, so the lower settings were unreachable on shorter terminals.
f.render_widget). A stateless ratatuiListhas no scroll offset, so it always draws from item 0 and never follows the selection. The visible highlight is faked by per-item span styling, so it moved on screen, but once the selection passed the viewport bottom the selected row went off-screen with no scroll.ListStateseeded fromsettings_selected_index(f.render_stateful_widget), mirroringdiscover.rs,util.rs, and every other list screen, so ratatui recomputes the offset each frame to keep the selection visible.Not actually platform-specific despite being reported on Windows: it only looked fine on Linux because that terminal was tall enough to show all 25 items at once.
Testing
Additional notes
▶highlight symbol, so the selected row now shows the▶arrow and all rows gain a 2-column left gutter for it. This matches the other list screens; no other layout or logic changes.