Skip to main content

slice_hunk_with_state

Function slice_hunk_with_state 

Source
pub fn slice_hunk_with_state(
    hunk: &DiffHunk,
    picked: &[bool],
    selected: &[bool],
) -> Result<DiffHunk>
Expand description

Slice a hunk using picked/selected state masks (for split command).

This builds a patch that correctly accounts for previously picked lines:

  • ‘+’ lines: selected -> keep, already picked -> context, else drop
  • ‘-’ lines: selected -> keep, already picked -> drop, else context
  • context: always keep

Both picked and selected are masks over hunk.lines (same length).