pub fn clamp_scroll(
selected: usize,
scroll_offset: usize,
visible_rows: usize,
total_rows: usize,
) -> usizeExpand description
Recompute scroll_offset so selected is inside the
visible_rows window. Pure — no Frame access.
- Cursor moved above the window: snap the window to the cursor.
- Cursor moved below the window: scroll just enough to keep it visible (one-line bumps, not page jumps — feels smoother in practice).
- List shrunk: clamp so the offset never points past the end.