Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/XTerm.NET.Tests/SelectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ public void SelectAll_IncludesScrollback_NotJustViewport()
Assert.Contains("Line7", selectedText);
}

[Fact]
public void SelectionText_UsesLineFeedLineEndings()
{
var terminal = new Terminal(new TerminalOptions { Rows = 3, Cols = 80, Scrollback = 20 });
terminal.Write("alpha\r\nbeta\r\ngamma");

terminal.Selection.StartSelection(0, 0);
terminal.Selection.UpdateSelection(4, 2);
terminal.Selection.EndSelection();

var selectedText = terminal.Selection.GetSelectionText();

Assert.DoesNotContain("\r", selectedText);
Assert.Equal(2, selectedText.Count(ch => ch == '\n'));
Assert.StartsWith("alpha", selectedText);
Assert.Contains("\nbeta", selectedText);
Assert.EndsWith("gamma", selectedText);
}

[Fact]
public void Selection_IsCleared_WhenTrimRemovesSelectedLines()
{
Expand Down
2 changes: 1 addition & 1 deletion src/XTerm.NET/Selection/SelectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public string GetSelectionText()
// Add line break if not last line and line doesn't wrap
if (y < end.y && !line.IsWrapped)
{
text.AppendLine();
text.Append('\n');
}
}

Expand Down