Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderer.cpp
Show First 20 Lines • Show All 378 Lines • ▼ Show 20 Line(s) | 361 | { | |||
---|---|---|---|---|---|
379 | 379 | | |||
380 | return false; | 380 | return false; | ||
381 | } | 381 | } | ||
382 | 382 | | |||
383 | QVector<QTextLayout::FormatRange> KateRenderer::decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly, KateRenderRange *completionHighlight, bool completionSelected) const | 383 | QVector<QTextLayout::FormatRange> KateRenderer::decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly, KateRenderRange *completionHighlight, bool completionSelected) const | ||
384 | { | 384 | { | ||
385 | QVector<QTextLayout::FormatRange> newHighlight; | 385 | QVector<QTextLayout::FormatRange> newHighlight; | ||
386 | 386 | | |||
387 | if (textLine->length() > 1024 && !selectionsOnly) { | ||||
mwolff: put the 1024 into a constant and use it here and below such that we ensure the number stays in… | |||||
388 | return newHighlight; | ||||
389 | } | ||||
390 | | ||||
387 | // Don't compute the highlighting if there isn't going to be any highlighting | 391 | // Don't compute the highlighting if there isn't going to be any highlighting | ||
388 | QList<Kate::TextRange *> rangesWithAttributes = m_doc->buffer().rangesForLine(line, m_printerFriendly ? nullptr : m_view, true); | 392 | QList<Kate::TextRange *> rangesWithAttributes = m_doc->buffer().rangesForLine(line, m_printerFriendly ? nullptr : m_view, true); | ||
389 | if (selectionsOnly || !textLine->attributesList().isEmpty() || !rangesWithAttributes.isEmpty()) { | 393 | if (selectionsOnly || !textLine->attributesList().isEmpty() || !rangesWithAttributes.isEmpty()) { | ||
390 | RenderRangeList renderRanges; | 394 | RenderRangeList renderRanges; | ||
391 | 395 | | |||
396 | if (textLine->length() <= 1024) { | ||||
couldn't the al.count be limited here? if I understand the patch correctly, we throw out all highlighting if we encounter too many ranges. but could we instead just skip the items that are beyond the limit? mwolff: couldn't the al.count be limited here? if I understand the patch correctly, we throw out all… | |||||
392 | // Add the inbuilt highlighting to the list | 397 | // Add the inbuilt highlighting to the list | ||
393 | NormalRenderRange *inbuiltHighlight = new NormalRenderRange(); | 398 | NormalRenderRange *inbuiltHighlight = new NormalRenderRange(); | ||
394 | const QVector<Kate::TextLineData::Attribute> &al = textLine->attributesList(); | 399 | const QVector<Kate::TextLineData::Attribute> &al = textLine->attributesList(); | ||
395 | for (int i = 0; i < al.count(); ++i) | 400 | for (int i = 0; i < al.count(); ++i) { | ||
mwolff: this style-change should be submitted independently of this code review | |||||
I figured that since I'm indenting the whole section and touching the line anyways, that fixing the style does not hurt. ;) (Phabricator is not showing the white-space change) sars: I figured that since I'm indenting the whole section and touching the line anyways, that fixing… | |||||
396 | if (al[i].length > 0 && al[i].attributeValue > 0) { | 401 | if (al[i].length > 0 && al[i].attributeValue > 0) { | ||
397 | inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue)); | 402 | inbuiltHighlight->addRange(new KTextEditor::Range(KTextEditor::Cursor(line, al[i].offset), al[i].length), specificAttribute(al[i].attributeValue)); | ||
398 | } | 403 | } | ||
404 | } | ||||
399 | renderRanges.append(inbuiltHighlight); | 405 | renderRanges.append(inbuiltHighlight); | ||
406 | } | ||||
400 | 407 | | |||
401 | if (!completionHighlight) { | 408 | if (!completionHighlight) { | ||
402 | // check for dynamic hl stuff | 409 | // check for dynamic hl stuff | ||
403 | const QSet<Kate::TextRange *> *rangesMouseIn = m_view ? m_view->rangesMouseIn() : nullptr; | 410 | const QSet<Kate::TextRange *> *rangesMouseIn = m_view ? m_view->rangesMouseIn() : nullptr; | ||
404 | const QSet<Kate::TextRange *> *rangesCaretIn = m_view ? m_view->rangesCaretIn() : nullptr; | 411 | const QSet<Kate::TextRange *> *rangesCaretIn = m_view ? m_view->rangesCaretIn() : nullptr; | ||
405 | bool anyDynamicHlsActive = m_view && (!rangesMouseIn->empty() || !rangesCaretIn->empty()); | 412 | bool anyDynamicHlsActive = m_view && (!rangesMouseIn->empty() || !rangesCaretIn->empty()); | ||
406 | 413 | | |||
407 | // sort all ranges, we want that the most specific ranges win during rendering, multiple equal ranges are kind of random, still better than old smart rangs behavior ;) | 414 | // sort all ranges, we want that the most specific ranges win during rendering, multiple equal ranges are kind of random, still better than old smart rangs behavior ;) | ||
▲ Show 20 Lines • Show All 806 Lines • Show Last 20 Lines |
put the 1024 into a constant and use it here and below such that we ensure the number stays in sync
also, don't we have a setting for the line length limit? shouldn't that be used instead here?