Commit 0c0c10b1 authored by David Schulz's avatar David Schulz

TextEditor: Fix block for visible row calculation

Take into account that a block can contain multiple visible rows.

Change-Id: Ifedeb113b3c1a6a374fa9418106e612c56559cba
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent b1a3c0bb
......@@ -8125,15 +8125,12 @@ QTextBlock TextEditorWidget::blockForVisibleRow(int row) const
return QTextBlock();
QTextBlock block = firstVisibleBlock();
for (int i = 0; i < count; ++i) {
if (!block.isValid() || i == row)
for (int i = 0; i < count;) {
if (!block.isValid() || i >= row)
return block;
while (block.isValid()) {
block = block.next();
if (block.isVisible())
break;
}
i += block.lineCount();
block = d->nextVisibleBlock(block);
}
return QTextBlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment