Commit 7fa8574d authored by mae's avatar mae
Browse files

fix extra area drawing with multi-line blocks when line wrap is enabled

The extra area only updated the current *line* when the cursor moved, not
the entire paragraph. This left bold line numbers behind. The fix adds
the required update region when the cursor position changes blocks.
parent 405d9367
......@@ -1479,7 +1479,8 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
m_inBlockSelectionMode(false),
m_lastEventWasBlockSelectionEvent(false),
m_blockSelectionExtraX(0),
m_moveLineUndoHack(false)
m_moveLineUndoHack(false),
m_cursorBlockNumber(-1)
{
}
......@@ -2781,6 +2782,22 @@ void BaseTextEditor::updateCurrentLineHighlight()
}
setExtraSelections(CurrentLineSelection, extraSelections);
// the extra area shows information for the entire current block, not just the currentline.
// This is why we must force a bigger update region.
int cursorBlockNumber = textCursor().blockNumber();
if (cursorBlockNumber != d->m_cursorBlockNumber) {
QPointF offset = contentOffset();
QTextBlock block = document()->findBlockByNumber(d->m_cursorBlockNumber);
if (block.isValid())
d->m_extraArea->update(blockBoundingGeometry(block).translated(offset).toAlignedRect());
block = document()->findBlockByNumber(cursorBlockNumber);
if (block.isValid())
d->m_extraArea->update(blockBoundingGeometry(block).translated(offset).toAlignedRect());
d->m_cursorBlockNumber = cursorBlockNumber;
}
}
void BaseTextEditor::slotCursorPositionChanged()
......
......@@ -243,6 +243,7 @@ public:
QTimer *m_highlightBlocksTimer;
QPointer<BaseTextEditorAnimator> m_animator;
int m_cursorBlockNumber;
};
......
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