diff options
author | David Schulz <david.schulz@qt.io> | 2022-12-16 12:10:29 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2022-12-16 11:34:02 +0000 |
commit | 1eb73e4eb31e6b8c8e6d1c38b588c2dba6762d0a (patch) | |
tree | b1d88009a45b33c3a2be2b828cfa0de6fc1699bf | |
parent | f87fccafc181db7844a95367f0253a0da1e230f5 (diff) |
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>
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index b9fda49c2e..d6bce9d5a0 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4483,8 +4483,10 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data, while (paintColumn < depth) { if (x >= 0) { 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; + } const QPointF top(x, blockData.boundingRect.top()); const QPointF bottom(x, blockData.boundingRect.top() + rect.height()); const QLineF line(top, bottom); |