Skip to main content

tui/diffs/
diff_types.rs

1/// Tag indicating the kind of change a diff line represents.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum DiffTag {
4    Context,
5    Removed,
6    Added,
7}
8
9/// A single line in a diff, tagged with its change type.
10#[derive(Debug, Clone, PartialEq)]
11pub struct DiffLine {
12    pub tag: DiffTag,
13    pub content: String,
14}
15
16/// A row in a side-by-side diff, pairing an old (left) line with a new (right) line.
17#[derive(Debug, Clone, PartialEq)]
18pub struct SplitDiffRow {
19    pub left: Option<SplitDiffCell>,
20    pub right: Option<SplitDiffCell>,
21}
22
23/// One side of a split diff row.
24#[derive(Debug, Clone, PartialEq)]
25pub struct SplitDiffCell {
26    pub tag: DiffTag,
27    pub content: String,
28    pub line_number: Option<usize>,
29}
30
31/// A preview of changed lines for an edit operation.
32#[derive(Debug, Clone, PartialEq)]
33pub struct DiffPreview {
34    /// Flat list of diff lines — used by the unified renderer.
35    pub lines: Vec<DiffLine>,
36    /// Paired rows — used by the split (side-by-side) renderer.
37    pub rows: Vec<SplitDiffRow>,
38    pub lang_hint: String,
39    /// 1-indexed line number where the edit begins in the original file.
40    pub start_line: Option<usize>,
41}