Skip to main content

hunk_scroll_offset

Function hunk_scroll_offset 

Source
pub fn hunk_scroll_offset(
    hunks: &[Hunk],
    selected: usize,
    pane_height: usize,
) -> usize
Expand description

Scroll offset (rows) that brings the selected hunk’s header into the diff pane: min(header offset, overflow). With the header at the pane top when it fits, and pinned to the last pane-height window when the hunk sits near the end of the diff. Pane taller than the whole diff → 0 (no scroll).

Final-review finding 2: selected_hunk is mutated by j/k, alt+↓/↑ and g/G but nothing consumed it — the pane always rendered from row 0, truncating long diffs. The row model assumes the default no-wrap rendering (one visual row per diff line); under wrap the true visual count can only grow, which makes this scroll conservative (the highlight still marks the selected hunk).