1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Hunk types for the diff subsystem.
//!
//! A `Hunk` carries the old-side and new-side line ranges that
//! `similar::TextDiff::from_lines` identified as differing, plus the
//! decision the user has made (or not yet made) about that change.
//!
//! Line ranges follow the half-open convention `[start_line,
//! end_line)` documented in `docs/diff-mode-plan.md` §3a — `end_line`
//! is the line index immediately past the hunk's last line. For
//! `HunkKind::Insert`, `old_lines.start == old_lines.end` (no
//! old-side content); for `HunkKind::Delete`, similarly
//! `new_lines.start == new_lines.end`.
use Range;
/// Stable per-hunk identifier. Monotonically allocated from
/// `DiffState::next_hunk_id` at construction and never reused — even
/// across hunk-list recomputations triggered by in-diff edits
/// (§6 "HunkId stability"). IDs survive index shifts, so
/// `DiffState::focused_id` (and the per-hunk decision matching across
/// a recompute) can reference a specific hunk without races against
/// recomputation.
;
/// Per-hunk decision recorded by the user during diff review.
/// Resolution proceeds only when every hunk's decision is
/// non-`Pending`.
/// Whether the hunk inserts, deletes, or replaces lines. Derived
/// from the emptiness of `old_lines` / `new_lines` at construction
/// — kept as an enum so `DiffView` can branch without re-checking
/// emptiness on every render frame.
/// A word-level inline highlight within a `Replace` hunk's old- or
/// new-side text. The span is expressed as a char range within the
/// concatenated old-side (resp. new-side) text of the hunk.
///
/// The engine wires the inline spans through to the renderer
/// but does not yet split table-row sub-hunks below the row level;
/// for `Insert` and `Delete` hunks the vec is empty.
/// A single contiguous diff hunk with stable id, line ranges, kind,
/// inline highlights, and current decision.