Skip to main content

render_diff

Function render_diff 

Source
pub fn render_diff(diff_text: &str) -> Vec<String>
Expand description

Render a unified diff string with colored lines and intra-line change highlighting. Matches pi’s renderDiff() in diff.ts.

Input format (from edit tool’s compute_diff): --- a/path / +++ b/path / @@ -1,5 +1,6 @@ / context / -removed / +added

Output: ANSI-styled lines with:

  • - lines: toolDiffRemoved (red)
  • + lines: toolDiffAdded (green)
  • lines: toolDiffContext (gray)
  • Single-line changes: intra-line diff with inverse highlighting