feat: fence review excerpts with language tags

This commit is contained in:
2026-10-25 00:13:35 +02:00
parent c1bff63111
commit 815fcccbe8
6 changed files with 94 additions and 5 deletions
+21 -3
View File
@@ -279,9 +279,24 @@ impl Review {
.filter(|comment| all || !comment.resolved)
{
let anchor = &comment.anchor;
let excerpt = anchor.excerpt();
let language =
match crate::syntax::language_id(Some(&anchor.path), anchor.content.lines().next())
{
Some("honey") => "hon",
language => language.unwrap_or(""),
};
let fence_width = 3.max(
excerpt
.split(|ch| ch != '`')
.map(str::len)
.max()
.unwrap_or(0)
+ 1,
);
writeln!(
text,
"\nComment {} [{}] {} ({}) {}:{}–{}:{} @ {}\n{}\n{}",
"\nComment {} [{}] {} ({}) {}:{}–{}:{} @ {}",
comment.id,
if comment.resolved {
"resolved"
@@ -298,10 +313,13 @@ impl Review {
anchor.end.row,
anchor.end.column,
anchor.revision,
anchor.excerpt(),
comment.body,
)
.unwrap();
write!(text, "{:`<fence_width$}{language}\n{excerpt}", "").unwrap();
if !excerpt.ends_with('\n') {
text.push('\n');
}
writeln!(text, "{:`<fence_width$}\n{}", "", comment.body).unwrap();
}
text
}