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

Function render_diff_file

atomic-cli/src/commands/triage/output.rs:590–619  ·  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

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