Skip to content

Commit

Permalink
fix: there's an extra line-ending while copy multiple lines from text…
Browse files Browse the repository at this point in the history
… diff view (#1049)

Signed-off-by: leo <longshuang@msn.cn>
  • Loading branch information
love-linger committed Mar 4, 2025
1 parent b75676a commit 96538b9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Views/TextDiffView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,18 +1032,32 @@ private void CopyWithoutIndicators()
line.Type == Models.TextDiffLineType.None)
continue;

// The first selected line (partial selection)
if (i == startIdx && startPosition.Column > 1)
{
builder.AppendLine(line.Content.Substring(startPosition.Column - 1));
continue;
}

if (i == endIdx && endPosition.Column < line.Content.Length)
// The selection range is larger than original source.
if (i == lines.Count - 1 && i < endIdx)
{
builder.AppendLine(line.Content.Substring(0, endPosition.Column - 1));
continue;
builder.Append(line.Content);
break;
}

// For the last line (selection range is within original source)
if (i == endIdx)
{
if (endPosition.Column < line.Content.Length)
builder.Append(line.Content.Substring(0, endPosition.Column - 1));
else
builder.Append(line.Content);

break;
}

// Other lines.
builder.AppendLine(line.Content);
}

Expand Down

0 comments on commit 96538b9

Please sign in to comment.