From e2ab24d36f31395c2239b49ac26f2266b69444bd Mon Sep 17 00:00:00 2001 From: Michal Lazo Date: Fri, 21 Sep 2018 11:30:06 +0200 Subject: [PATCH] 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 --- src/widgets/widgets/qwidgettextcontrol.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 77351d3346..5f17d19872 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -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;