Skip to content

Commit dbceb5b

Browse files
committed
fix: Prevent extra newlines when copy lines
1 parent 5301a36 commit dbceb5b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/Views/TextDiffView.axaml.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,17 +1034,20 @@ private void CopyWithoutIndicators()
10341034

10351035
if (i == startIdx && startPosition.Column > 1)
10361036
{
1037-
builder.AppendLine(line.Content.Substring(startPosition.Column - 1));
1038-
continue;
1037+
builder.Append(line.Content.Substring(startPosition.Column - 1));
10391038
}
1040-
1041-
if (i == endIdx && endPosition.Column < line.Content.Length)
1039+
else if (i == endIdx && endPosition.Column < line.Content.Length)
10421040
{
1043-
builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1));
1044-
continue;
1041+
if (builder.Length > 0)
1042+
builder.AppendLine();
1043+
builder.Append(line.Content.Substring(0, endPosition.Column - 1));
1044+
}
1045+
else
1046+
{
1047+
if (builder.Length > 0)
1048+
builder.AppendLine();
1049+
builder.Append(line.Content);
10451050
}
1046-
1047-
builder.AppendLine(line.Content);
10481051
}
10491052

10501053
App.CopyText(builder.ToString());

0 commit comments

Comments
 (0)