From 1eb73e4eb31e6b8c8e6d1c38b588c2dba6762d0a Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 16 Dec 2022 12:10:29 +0100 Subject: [PATCH] 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 --- src/plugins/texteditor/texteditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index b9fda49c2ed..d6bce9d5a0b 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);