Skip to main content

Module diff

Module diff 

Source

Enums§

DiffLine
A single line in a diff hunk — either kept, removed, or added.

Functions§

compute_diff
Compute the shortest edit script between old and new.
compute_edit_diff_from_path
Compute a diff for an edit operation and return it as a plain-text string (no ANSI codes). Reads the current file content to locate the edit.
compute_edit_diff_plain
Compute a unified diff between old and new content and return it as a plain-text string (no ANSI codes). Returns an empty string if the contents are identical.
compute_write_diff_plain
Compute a diff for a write operation (file creation or modification) and return it as a plain-text string (no ANSI codes).
render_diff_plain
Render a DiffLine sequence into a plain-text string (no ANSI codes).
show_edit_diff
Show a unified-diff-style view of an edit operation. Reads the file, locates old_str, and prints context lines with the removed text in red and the replacement in green.
show_write_preview
Show a unified-diff-style view of a write operation (full file). If the file already exists, reads it and shows a line-by-line diff with removed lines in red and added lines in green. If the file is new, shows a preview of the content that will be written.