feat: fence review excerpts with language tags
This commit is contained in:
+21
-3
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user