move_sel_cached

Function move_sel_cached 

Source
pub fn move_sel_cached(
    app: &mut AppState,
    delta: isize,
    details_tx: &UnboundedSender<PackageItem>,
    comments_tx: &UnboundedSender<String>,
)
Expand description

What: Move the selection by delta and coordinate detail loading policies.

Inputs:

  • app: Mutable application state (results, selection, caches, scroll heuristics).
  • delta: Signed offset to apply to the current selection index.
  • details_tx: Channel used to request lazy loading of package details.
  • comments_tx: Channel used to request AUR package comments.

Output:

  • Updates selection-related state, potentially sends detail requests, and adjusts gating flags.

ยงPanics

  • Panics if abs_delta_usize exceeds u32::MAX when converting to u32
  • May panic if app.list_state.select is called with an invalid index (depends on the list state implementation)

Details:

  • Clamps the selection to valid bounds, refreshes placeholder metadata, and reuses cached entries.
  • Schedules PKGBUILD reloads when necessary and tracks scroll velocity to throttle prefetching.
  • Updates comments when package changes and comments are visible (only for AUR packages).
  • Switches between selected-only gating during fast scrolls and wide ring prefetch for slower navigation.