From bfdda368a9a2b3c2e098379a6ab8ee6c7f8aaf9a Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 11 Jul 2024 09:22:12 +0200 Subject: [PATCH] TextEditor: optimize folding highlight only try to get the cursorForPosition if the mouse cursor is above the folding region. Change-Id: I81efdcfc84dc4d1bab696c57de8732e819ea4b72 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 3d02ed06142..f973cfe9cc3 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -7105,8 +7105,6 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos) if (!d->m_codeFoldingVisible) return; - QTextCursor cursor = cursorForPosition(QPoint(0, pos.y())); - // Update which folder marker is highlighted int boxWidth = 0; if (TextEditorSettings::fontSettings().relativeLineSpacing() == 100) @@ -7114,14 +7112,13 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos) else boxWidth = foldBoxWidth(); - if (pos.x() > extraArea()->width() - boxWidth) { - updateFoldingHighlight(cursor); - } else if (d->m_displaySettings.m_highlightBlocks) { - QTextCursor cursor = textCursor(); - updateFoldingHighlight(cursor); - } else { - updateFoldingHighlight(QTextCursor()); - } + QTextCursor cursor; + if (pos.x() > extraArea()->width() - boxWidth) + cursor = cursorForPosition(QPoint(0, pos.y())); + else if (d->m_displaySettings.m_highlightBlocks) + cursor = textCursor(); + + updateFoldingHighlight(cursor); } void TextEditorWidget::updateFoldingHighlight(const QTextCursor &cursor)