MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / render_diff_file

Function render_diff_file

atomic-cli/src/commands/triage/output.rs:586–615  ·  view source on GitHub ↗

One file's color-coded unified diff — shared by the per-change view and the walkthrough chapters, so both render diffs identically.

(f: &DiffFileView)

Source from the content-addressed store, hash-verified

584/// One file's color-coded unified diff — shared by the per-change view and the
585/// walkthrough chapters, so both render diffs identically.
586fn render_diff_file(f: &DiffFileView) -> String {
587 let mut s = String::new();
588 s.push_str(&format!(
589 "<div class=\"diff-file\"><span class=\"diff-path\">{}</span> <span class=\"diff-status {}\">{}</span></div>\n",
590 html_escape(&f.path),
591 html_escape(&f.status),
592 html_escape(&f.status)
593 ));
594 s.push_str("<pre class=\"diff\">");
595 for hunk in &f.hunks {
596 s.push_str(&format!(
597 "<div class=\"hunk-header\">{}</div>",
598 html_escape(&hunk.header)
599 ));
600 for line in &hunk.lines {
601 let cls = match line.tag.as_str() {
602 "+" => "add",
603 "-" => "del",
604 _ => "ctx",
605 };
606 s.push_str(&format!(
607 "<div class=\"line {cls}\">{}{}</div>",
608 html_escape(&line.tag),
609 html_escape(&line.content)
610 ));
611 }
612 }
613 s.push_str("</pre>\n");
614 s
615}
616
617/// The walkthrough section: a reading-order nav plus one numbered collapsible
618/// chapter per layer (first chapter open). Each chapter shows the canonical

Callers 2

render_changeFunction · 0.85
render_walkthroughFunction · 0.85

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected