Skip to content

Commit 35ee4a4

Browse files
committed
fix: the last selected line is missing while trying to copy multiple lines in text diff view (#1044)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 598bba5 commit 35ee4a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Views/TextDiffView.axaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@ private void CopyWithoutIndicators()
10071007
if (startPosition.Location > endPosition.Location)
10081008
(startPosition, endPosition) = (endPosition, startPosition);
10091009

1010-
var startIdx = Math.Min(startPosition.Line - 1, lines.Count - 1);
1011-
var endIdx = Math.Min(endPosition.Line - 1, lines.Count - 1);
1010+
var startIdx = startPosition.Line - 1;
1011+
var endIdx = endPosition.Line - 1;
10121012

10131013
if (startIdx == endIdx)
10141014
{
@@ -1025,7 +1025,7 @@ private void CopyWithoutIndicators()
10251025
}
10261026

10271027
var builder = new StringBuilder();
1028-
for (var i = startIdx; i <= endIdx; i++)
1028+
for (var i = startIdx; i <= endIdx && i <= lines.Count - 1; i++)
10291029
{
10301030
var line = lines[i];
10311031
if (line.Type == Models.TextDiffLineType.Indicator ||
@@ -1040,7 +1040,7 @@ private void CopyWithoutIndicators()
10401040

10411041
if (i == endIdx && endPosition.Column < line.Content.Length)
10421042
{
1043-
builder.AppendLine(line.Content.Substring(0, endPosition.Column));
1043+
builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1));
10441044
continue;
10451045
}
10461046

0 commit comments

Comments
 (0)