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>
This commit is contained in:
David Schulz
2020-06-08 13:30:17 +02:00
parent ba580bba83
commit 3f08961322

View File

@@ -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;
}