Module diff_hunk

Module diff_hunk 

Source
Expand description

Diff hunk representation.

A hunk is a contiguous section of a diff, representing a group of related changes. Each hunk starts with a header line like @@ -1,4 +1,5 @@ context that indicates the line ranges in both the old and new versions.

§Structure

  • DiffHunk - The diff hunk struct
  • constructors - Constructor functions (new, from_header)
  • methods - Instance methods for working with hunks

§Example

use ratatui_toolkit::code_diff::{DiffHunk, DiffLine};

let mut hunk = DiffHunk::new(1, 4, 1, 5);
hunk.add_line(DiffLine::context("unchanged", 1, 1));
hunk.add_line(DiffLine::removed("old line", 2));
hunk.add_line(DiffLine::added("new line", 2));

Modules§

constructors
Constructor functions for DiffHunk.
methods
Instance methods for DiffHunk.

Structs§

DiffHunk
Represents a single hunk (section) in a diff.