From dbceb5b6c0a7d7e77157bda1856ee4babe8ab35a Mon Sep 17 00:00:00 2001 From: Gadfly Date: Tue, 4 Mar 2025 15:38:29 +0800 Subject: [PATCH] fix: Prevent extra newlines when copy lines --- src/Views/TextDiffView.axaml.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 958e803e..b67d6633 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -1034,17 +1034,20 @@ namespace SourceGit.Views if (i == startIdx && startPosition.Column > 1) { - builder.AppendLine(line.Content.Substring(startPosition.Column - 1)); - continue; + builder.Append(line.Content.Substring(startPosition.Column - 1)); } - - if (i == endIdx && endPosition.Column < line.Content.Length) + else if (i == endIdx && endPosition.Column < line.Content.Length) { - builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1)); - continue; + if (builder.Length > 0) + builder.AppendLine(); + builder.Append(line.Content.Substring(0, endPosition.Column - 1)); + } + else + { + if (builder.Length > 0) + builder.AppendLine(); + builder.Append(line.Content); } - - builder.AppendLine(line.Content); } App.CopyText(builder.ToString());