Editor: prevent validating line number in unwrapped editor

Checking whether a position is inside the first line is also not for
free. Only check the line number of a cursor position if we expect the
editor to have multiple lines per block or in other words line wrapping is
enabled.

Change-Id: I0e3cb1fbd11c250677f7c11d1a5c780f60085ec2
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
David Schulz
2022-12-16 12:10:29 +01:00
parent f87fccafc1
commit 1eb73e4eb3

View File

@@ -4483,8 +4483,10 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
while (paintColumn < depth) { while (paintColumn < depth) {
if (x >= 0) { if (x >= 0) {
int paintPosition = tabSettings.positionAtColumn(text, paintColumn); int paintPosition = tabSettings.positionAtColumn(text, paintColumn);
if (blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0) if (q->lineWrapMode() == QPlainTextEdit::WidgetWidth
&& blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0) {
break; break;
}
const QPointF top(x, blockData.boundingRect.top()); const QPointF top(x, blockData.boundingRect.top());
const QPointF bottom(x, blockData.boundingRect.top() + rect.height()); const QPointF bottom(x, blockData.boundingRect.top() + rect.height());
const QLineF line(top, bottom); const QLineF line(top, bottom);