Skip to content

Commit 96538b9

Browse files
committed
fix: there's an extra line-ending while copy multiple lines from text diff view (#1049)
Signed-off-by: leo <longshuang@msn.cn>
1 parent b75676a commit 96538b9

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Views/TextDiffView.axaml.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,18 +1032,32 @@ private void CopyWithoutIndicators()
10321032
line.Type == Models.TextDiffLineType.None)
10331033
continue;
10341034

1035+
// The first selected line (partial selection)
10351036
if (i == startIdx && startPosition.Column > 1)
10361037
{
10371038
builder.AppendLine(line.Content.Substring(startPosition.Column - 1));
10381039
continue;
10391040
}
10401041

1041-
if (i == endIdx && endPosition.Column < line.Content.Length)
1042+
// The selection range is larger than original source.
1043+
if (i == lines.Count - 1 && i < endIdx)
10421044
{
1043-
builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1));
1044-
continue;
1045+
builder.Append(line.Content);
1046+
break;
1047+
}
1048+
1049+
// For the last line (selection range is within original source)
1050+
if (i == endIdx)
1051+
{
1052+
if (endPosition.Column < line.Content.Length)
1053+
builder.Append(line.Content.Substring(0, endPosition.Column - 1));
1054+
else
1055+
builder.Append(line.Content);
1056+
1057+
break;
10451058
}
10461059

1060+
// Other lines.
10471061
builder.AppendLine(line.Content);
10481062
}
10491063

0 commit comments

Comments
 (0)