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
/* This file is part of the OmniDiff code diffing tool.
*
* Copyright (C) 2026 Marko Ivankovic
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Syntax-aware code diffing on tree-sitter ASTs.
//!
//! [`diff_strings`] is the entry point: it parses both sides into [`code::Code`] and returns a
//! [`diff::Diff`]: the mapping between the two syntax trees plus the changed text ranges it implies.
//! The `tui` feature adds the terminal viewer built on it.
//!
//! # Stability
//!
//! This crate is published for the `omnidiff` binary. Its stable contracts are the command line
//! and the `--mode json` output, which the editor integrations consume. The library API - the
//! `diff` module's submodules (`apted`, `cost`, `nodes`, `text`, `text_range`), the `tui` module,
//! and the `tree_sitter` and `ratatui` types in their signatures - is the binary's internals made
//! visible, and changes between 0.x minor versions without notice. [`diff_strings`] and the
//! [`code`] and [`diff`] module roots are the parts meant for use from another crate.
// Needs no TUI dependency itself, but its one consumer (the TUI's review picker) is behind `tui`, so
// it shares that gate rather than widen a `default-features = false` consumer's surface.
// The GitHub Pages showcase's data, for src/bin/generate_showcase.rs alone.
// Unit tests across the crate use `crate::test::helper` whatever the features, so `cfg(test)` always
// sees it; `test-fixtures` exposes it to the src/bin/ tools that depend on it outside tests.
use crate::;
/// Diffs two programs given as source strings in `language`.