Expand description
A diff view over ashlar_diff::FileDiffs: unified or split, virtualized, syntax-coloured per
file language, with word-level emphasis, collapsed unchanged ranges, a sticky file header,
line selection and hunk navigation.
A frame costs O(visible rows). The row model (files, hunk headers, lines, collapsed ranges)
is built once per (revision, mode, expansion) and kept by the view. Lexer states run
lazily within each hunk, so jumping to the end of a long diff highlights one hunk, not the
whole diff. Row galleys are cached and rebuilt only when the model, the theme or the font
changes.
let out = DiffView::new("review.diff", state, files, revision).mode(DiffMode::Split).show(ui);
for line in &out.selected_lines {
// comment on `line.file`, `line.new_no`…
}Lines wider than the view scroll sideways (both sides of a split together): the horizontal wheel (Shift+wheel) over the view, or a drag on the thin bar along its bottom.
Input: click selects a row, Shift-click and Shift+arrows extend, ⌘-click toggles. N / F7
moves to the next hunk, P / Shift+F7 to the previous one. Clicking (or Enter on) a
collapsed range shows EXPAND_STEP more lines, Alt-click shows all of them. Clicking a file
header (or Enter on it) folds the file; clicking the sticky header jumps to its file.
Automation (visible rows only, indices 0-based): <id>.file.<f> (file header),
<id>.file.<f>.hunk.<h> (hunk header), <id>.file.<f>.hunk.<h>.line.<k> (line k of the
hunk; in split mode the left line, else the right), <id>.file.<f>.gap.<g> (collapsed range),
<id>.file.<f>.gap.<g>.line.<n> (expanded line, n its new line number) and <id>.header
(the sticky header). AccessKit: the view is a read-only document; file and hunk headers are
headings, collapsed ranges buttons, lines paragraphs labelled “added 12: text”.
Structs§
- Diff
Labels - Words the view shows (localized by the app).
- Diff
Response - What the view reports this frame.
- Diff
View - A diff view. See the module docs.
- Diff
View State - The view’s state, kept by the app: selection, expanded ranges, folded files.
- Selected
Line - One selected line.
Enums§
- Diff
Mode - How lines are laid out.
Constants§
- EXPAND_
STEP - Lines one click on a collapsed range reveals.
- MAX_
SELECTED_ LINES - Most entries
DiffResponse::selected_lineslists.