summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2020-06-08 13:30:17 +0200
committerDavid Schulz <david.schulz@qt.io>2020-06-11 06:52:01 +0000
commit3f089613227784b6b0aaf45b4648af29ea7e3379 (patch)
tree2ea9772e4ed8980551de739ae7895c3d68f7d1df
parentba580bba83a261e6327334b947c01fa172b30362 (diff)
downloadqt-creator-3f089613227784b6b0aaf45b4648af29ea7e3379.tar.gz
Utils: fix selectAt used with invisible blocks
Using QTextCursor::movePosition with QTextCursor::NextBlock seems to jump over invisible blocks. Use setPosition instead. Change-Id: I3271fb8570678ef6f09141032948dedee308e20c Fixes: QTCREATORBUG-24019 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/libs/utils/textutils.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/libs/utils/textutils.cpp b/src/libs/utils/textutils.cpp
index bc81867768..3b475aef3c 100644
--- a/src/libs/utils/textutils.cpp
+++ b/src/libs/utils/textutils.cpp
@@ -88,11 +88,9 @@ QTextCursor selectAt(QTextCursor textCursor, int line, int column, uint length)
if (column < 1)
column = 1;
- textCursor.setPosition(0);
- textCursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, line - 1);
- textCursor.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor, column + length - 1 );
-
- textCursor.movePosition(QTextCursor::PreviousCharacter,QTextCursor::KeepAnchor, length);
+ const int anchorPosition = positionInText(textCursor.document(), line, column + length);
+ textCursor.setPosition(anchorPosition);
+ textCursor.setPosition(anchorPosition - length, QTextCursor::KeepAnchor);
return textCursor;
}