diff --git a/src/render/katerenderer.cpp b/src/render/katerenderer.cpp --- a/src/render/katerenderer.cpp +++ b/src/render/katerenderer.cpp @@ -384,19 +384,26 @@ { QVector newHighlight; + if (textLine->length() > 1024 && !selectionsOnly) { + return newHighlight; + } + // Don't compute the highlighting if there isn't going to be any highlighting QList rangesWithAttributes = m_doc->buffer().rangesForLine(line, m_printerFriendly ? nullptr : m_view, true); if (selectionsOnly || !textLine->attributesList().isEmpty() || !rangesWithAttributes.isEmpty()) { RenderRangeList renderRanges; - // Add the inbuilt highlighting to the list - NormalRenderRange *inbuiltHighlight = new NormalRenderRange(); - const QVector &al = textLine->attributesList(); - for (int i = 0; i < al.count(); ++i) - if (al[i].length > 0 && al[i].attributeValue > 0) { - inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue)); + if (textLine->length() <= 1024) { + // Add the inbuilt highlighting to the list + NormalRenderRange *inbuiltHighlight = new NormalRenderRange(); + const QVector &al = textLine->attributesList(); + for (int i = 0; i < al.count(); ++i) { + if (al[i].length > 0 && al[i].attributeValue > 0) { + inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue)); + } } - renderRanges.append(inbuiltHighlight); + renderRanges.append(inbuiltHighlight); + } if (!completionHighlight) { // check for dynamic hl stuff diff --git a/src/view/kateview.cpp b/src/view/kateview.cpp --- a/src/view/kateview.cpp +++ b/src/view/kateview.cpp @@ -3315,7 +3315,9 @@ KTextEditor::Range KTextEditor::ViewPrivate::visibleRange() { //ensure that the view is up-to-date, otherwise 'endPos()' might fail! - m_viewInternal->updateView(); + if (!m_viewInternal->endPos().isValid()) { + m_viewInternal->updateView(); + } return KTextEditor::Range(m_viewInternal->toRealCursor(m_viewInternal->startPos()), m_viewInternal->toRealCursor(m_viewInternal->endPos())); } @@ -3639,7 +3641,9 @@ attr->setForeground(fgColor); attr->setBackground(bgColor); - KTextEditor::Cursor start(visibleRange().start()); + KTextEditor::Range tmpVisibleRange = visibleRange(); + + KTextEditor::Cursor start(tmpVisibleRange.start()); KTextEditor::Range searchRange; /** @@ -3654,7 +3658,7 @@ QVector matches; do { - searchRange.setRange(start, visibleRange().end()); + searchRange.setRange(start, tmpVisibleRange.end()); matches = m_doc->searchText(searchRange, regex, KTextEditor::Regex);