Move cursor selection to start when there isn't any previous line in selection mode

Adding standard behavior for text selection, when user want to select text
and there isn't any previous line then selection will end on start

[ChangeLog][QtWidgets][QWidgetTextControlPrivate] Move cursor selection to start

Task-number: QTBUG-69735
Change-Id: If222d37747772f60774f671ffdd273d63cdaf571
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Michal Lazo 2018-09-21 11:30:06 +02:00 committed by Allan Sandfeld Jensen
parent 5a52890a85
commit e2ab24d36f

View File

@ -218,6 +218,14 @@ bool QWidgetTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
else if (e == QKeySequence::SelectPreviousLine) {
op = QTextCursor::Up;
mode = QTextCursor::KeepAnchor;
{
QTextBlock block = cursor.block();
QTextLine line = currentTextLine(cursor);
if (!block.previous().isValid()
&& line.isValid()
&& line.lineNumber() == 0)
op = QTextCursor::Start;
}
}
else if (e == QKeySequence::SelectNextLine) {
op = QTextCursor::Down;