pub fn clamp_selection(current: Option<usize>, len: usize) -> Option<usize>Expand description
Clamp a selection index after a list has been resized.
- If the list is empty →
None(nothing to select). - If no index was selected →
Some(0)(auto-select first item). - Otherwise → the existing index clamped to
0..len.