TextEditor: only paint selections in the first block of a suggestion

Fixes highlighting of matching parentheses or errors of the code model
in every line of the suggestion.

Change-Id: I223cb567ee8ce95badd91c4819417310a0e28cff
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
David Schulz
2023-03-17 14:13:01 +01:00
parent 31d6990ab8
commit d6c5cf5934

View File

@@ -4994,7 +4994,13 @@ void TextEditorWidget::paintBlock(QPainter *painter,
QPointF replacementOffset = offset;
replacementOffset.rx() += document()->documentMargin();
while (replacementBlock.isValid()) {
replacementBlock.layout()->draw(painter, replacementOffset, selections, clipRect);
const QVector<QTextLayout::FormatRange> blockSelections
= replacementBlock.blockNumber() == 0 ? selections
: QVector<QTextLayout::FormatRange>{};
replacementBlock.layout()->draw(painter,
replacementOffset,
blockSelections,
clipRect);
replacementOffset.ry()
+= replacement->documentLayout()->blockBoundingRect(replacementBlock).height();
replacementBlock = replacementBlock.next();