public static void Up(TextEditorData data)
{
using (var undo = data.OpenUndoGroup()) {
int desiredColumn = data.Caret.DesiredColumn;
//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.MinLine - 1;
data.ClearSelection();
data.Caret.Location = (line >= DocumentLocation.MinLine) ? new DocumentLocation(line, col) : new DocumentLocation(DocumentLocation.MinLine, DocumentLocation.MinColumn);
data.Caret.SetToDesiredColumn(desiredColumn);
return;
}
if (data.Caret.Line > DocumentLocation.MinLine)
{
int visualLine = data.LogicalToVisualLine(data.Caret.Line);
int line = data.VisualToLogicalLine(visualLine - 1);
int offset = MoveCaretOutOfFolding(data, data.Document.LocationToOffset(line, data.Caret.Column), false);
data.Caret.SetToOffsetWithDesiredColumn(offset);
}
else
{
ToDocumentStart(data);
}
}
}