From d822afc4ec321dddd717509ea6bb76b7ed102462 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 3 Jul 2024 15:34:29 +0800 Subject: [PATCH] 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 --- src/Views/TextDiffView.axaml.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 22ee8123..5e925686 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -429,7 +429,18 @@ namespace SourceGit.Views { var builder = new StringBuilder(); foreach (var line in textDiff.Lines) - builder.AppendLine(line.Content); + { + 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); + } + } Text = builder.ToString(); } @@ -718,7 +729,18 @@ namespace SourceGit.Views var builder = new StringBuilder(); var lines = IsOld ? diff.Old : diff.New; foreach (var line in lines) - builder.AppendLine(line.Content); + { + 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); + } + } Text = builder.ToString(); }