1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-29 02:29:55 +03:00

Improve diff display for edited messages

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-06-30 22:00:38 +05:00
parent 63484ac353
commit 4595638cdb
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 10 additions and 6 deletions

View file

@ -122,11 +122,16 @@ public static class Extensions {
return WebUtility.UrlEncode(s).Replace('+', ' ');
}
public static string AsMarkdown(this SideBySideDiffModel model) {
public static string AsMarkdown(this DiffPaneModel model) {
var builder = new StringBuilder();
foreach (var line in model.OldText.Lines.Where(piece => !string.IsNullOrWhiteSpace(piece.Text)))
builder.Append("-- ").AppendLine(line.Text);
foreach (var line in model.NewText.Lines) builder.Append("++ ").AppendLine(line.Text);
foreach (var line in model.Lines) {
if (line.Type is ChangeType.Deleted)
builder.Append("-- ");
if (line.Type is ChangeType.Inserted)
builder.Append("++ ");
if (line.Type is not ChangeType.Imaginary)
builder.AppendLine(line.Text);
}
return Markdown.BlockCode(builder.ToString().SanitizeForBlockCode(), "diff");
}