summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextcursor.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 51db578..e6af105 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -421,11 +421,18 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
break;
}
case QTextCursor::PreviousCharacter:
- newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
+ if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
+ newPosition = qMin(position, adjusted_anchor);
+ else
+ newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
break;
case QTextCursor::Left:
- newPosition = visualMovement ? priv->leftCursorPosition(position)
- : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
+ if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
+ newPosition = visualMovement ? qMax(position, adjusted_anchor)
+ : qMin(position, adjusted_anchor);
+ else
+ newPosition = visualMovement ? priv->leftCursorPosition(position)
+ : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
break;
case QTextCursor::StartOfWord: {
if (relativePos == 0)
@@ -535,11 +542,18 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
break;
}
case QTextCursor::NextCharacter:
- newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
+ if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
+ newPosition = qMax(position, adjusted_anchor);
+ else
+ newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
break;
case QTextCursor::Right:
- newPosition = visualMovement ? priv->rightCursorPosition(position)
- : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
+ if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
+ newPosition = visualMovement ? qMin(position, adjusted_anchor)
+ : qMax(position, adjusted_anchor);
+ else
+ newPosition = visualMovement ? priv->rightCursorPosition(position)
+ : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
break;
case QTextCursor::NextWord:
case QTextCursor::WordRight: