forked from qt-creator/qt-creator
TextEditor: prefilter refactor markers before painting
This prevents calculating the block bounding rect for blocks outside of the cliprect. Change-Id: I416f1e6f71ae7e87fcc208f3eb3eb69300c9a1f8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -24,14 +24,21 @@ RefactorOverlay::RefactorOverlay(TextEditor::TextEditorWidget *editor) :
|
||||
|
||||
void RefactorOverlay::paint(QPainter *painter, const QRect &clip)
|
||||
{
|
||||
const auto firstBlock = m_editor->blockForVerticalOffset(clip.top());
|
||||
const auto lastBlock = m_editor->blockForVerticalOffset(clip.bottom());
|
||||
|
||||
m_maxWidth = 0;
|
||||
for (auto &marker : std::as_const(m_markers)) {
|
||||
for (const RefactorMarker &marker : std::as_const(m_markers)) {
|
||||
const int markerBlockNumber = marker.cursor.block().blockNumber();
|
||||
if (markerBlockNumber < firstBlock.blockNumber())
|
||||
continue;
|
||||
if (markerBlockNumber > lastBlock.blockNumber())
|
||||
continue;
|
||||
paintMarker(marker, painter, clip);
|
||||
}
|
||||
|
||||
if (auto documentLayout = qobject_cast<TextDocumentLayout*>(m_editor->document()->documentLayout()))
|
||||
documentLayout->setRequiredWidth(m_maxWidth);
|
||||
|
||||
}
|
||||
|
||||
RefactorMarker RefactorOverlay::markerAt(const QPoint &pos) const
|
||||
|
||||
Reference in New Issue
Block a user