ux: trim text in diff editor if length of line is greater than 10000 (#234)

* ignore WordWrap while trimming text, because displaying the full content content with a length greater than 10000 is meaningless
This commit is contained in:
leo 2024-07-03 15:34:29 +08:00
parent f4f4a26a64
commit d822afc4ec
No known key found for this signature in database

View file

@ -429,7 +429,18 @@ namespace SourceGit.Views
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
foreach (var line in textDiff.Lines) foreach (var line in textDiff.Lines)
{
if (line.Content.Length > 10000)
{
builder.Append(line.Content.Substring(0, 1000));
builder.Append($"...({line.Content.Length - 1000} character trimmed)");
builder.AppendLine();
}
else
{
builder.AppendLine(line.Content); builder.AppendLine(line.Content);
}
}
Text = builder.ToString(); Text = builder.ToString();
} }
@ -718,7 +729,18 @@ namespace SourceGit.Views
var builder = new StringBuilder(); var builder = new StringBuilder();
var lines = IsOld ? diff.Old : diff.New; var lines = IsOld ? diff.Old : diff.New;
foreach (var line in lines) foreach (var line in lines)
{
if (line.Content.Length > 10000)
{
builder.Append(line.Content.Substring(0, 1000));
builder.Append($"...({line.Content.Length - 1000} characters trimmed)");
builder.AppendLine();
}
else
{
builder.AppendLine(line.Content); builder.AppendLine(line.Content);
}
}
Text = builder.ToString(); Text = builder.ToString();
} }