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)
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) {
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);
} else if (d->m_displaySettings.m_highlightBlocks) {
QTextCursor cursor = textCursor();
updateFoldingHighlight(cursor);
} else {
updateFoldingHighlight(QTextCursor());
}
}
void TextEditorWidget::updateFoldingHighlight(const QTextCursor &cursor)