From 35ee4a47db9b2124699fbcfac9148c68bd238a23 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 3 Mar 2025 15:39:59 +0800 Subject: [PATCH] fix: the last selected line is missing while trying to copy multiple lines in text diff view (#1044) Signed-off-by: leo --- src/Views/TextDiffView.axaml.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index dccbb9b2..958e803e 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -1007,8 +1007,8 @@ namespace SourceGit.Views if (startPosition.Location > endPosition.Location) (startPosition, endPosition) = (endPosition, startPosition); - var startIdx = Math.Min(startPosition.Line - 1, lines.Count - 1); - var endIdx = Math.Min(endPosition.Line - 1, lines.Count - 1); + var startIdx = startPosition.Line - 1; + var endIdx = endPosition.Line - 1; if (startIdx == endIdx) { @@ -1025,7 +1025,7 @@ namespace SourceGit.Views } var builder = new StringBuilder(); - for (var i = startIdx; i <= endIdx; i++) + for (var i = startIdx; i <= endIdx && i <= lines.Count - 1; i++) { var line = lines[i]; if (line.Type == Models.TextDiffLineType.Indicator || @@ -1040,7 +1040,7 @@ namespace SourceGit.Views if (i == endIdx && endPosition.Column < line.Content.Length) { - builder.AppendLine(line.Content.Substring(0, endPosition.Column)); + builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1)); continue; }