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 <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2024-07-11 09:22:12 +02:00
parent 496cd41d24
commit bfdda368a9

View File

@@ -7105,8 +7105,6 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
if (!d->m_codeFoldingVisible) if (!d->m_codeFoldingVisible)
return; return;
QTextCursor cursor = cursorForPosition(QPoint(0, pos.y()));
// Update which folder marker is highlighted // Update which folder marker is highlighted
int boxWidth = 0; int boxWidth = 0;
if (TextEditorSettings::fontSettings().relativeLineSpacing() == 100) if (TextEditorSettings::fontSettings().relativeLineSpacing() == 100)
@@ -7114,14 +7112,13 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
else else
boxWidth = foldBoxWidth(); boxWidth = foldBoxWidth();
if (pos.x() > extraArea()->width() - boxWidth) { QTextCursor cursor;
updateFoldingHighlight(cursor); if (pos.x() > extraArea()->width() - boxWidth)
} else if (d->m_displaySettings.m_highlightBlocks) { cursor = cursorForPosition(QPoint(0, pos.y()));
QTextCursor cursor = textCursor(); else if (d->m_displaySettings.m_highlightBlocks)
updateFoldingHighlight(cursor); cursor = textCursor();
} else {
updateFoldingHighlight(QTextCursor()); updateFoldingHighlight(cursor);
}
} }
void TextEditorWidget::updateFoldingHighlight(const QTextCursor &cursor) void TextEditorWidget::updateFoldingHighlight(const QTextCursor &cursor)