public static void Down(TextEditorData data)
{
using (var undo = data.OpenUndoGroup()) {
//on Mac, when deselecting and moving up/down a line, column is always the column of the selection's start
if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection)
{
int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column;
int line = data.MainSelection.MaxLine + 1;
data.ClearSelection();
if (line <= data.Document.LineCount)
{
int offset = data.Document.LocationToOffset(line, col);
data.Caret.SetToOffsetWithDesiredColumn(MoveCaretOutOfFolding(data, offset));
}
else
{
data.Caret.Offset = data.Document.TextLength;
}
return;
}
if (data.Caret.Line < data.Document.LineCount)
{
int nextLine = data.LogicalToVisualLine(data.Caret.Line) + 1;
int line = data.VisualToLogicalLine(nextLine);
int offset = MoveCaretOutOfFolding(data, data.LocationToOffset(line, data.Caret.Column), true);
data.Caret.SetToOffsetWithDesiredColumn(offset);
}
else
{
ToDocumentEnd(data);
}
}
}