diff --git a/src/buffer/katetextbuffer.cpp b/src/buffer/katetextbuffer.cpp --- a/src/buffer/katetextbuffer.cpp +++ b/src/buffer/katetextbuffer.cpp @@ -68,7 +68,7 @@ , m_generateByteOrderMark(false) , m_endOfLineMode(eolUnix) , m_newLineAtEof(false) - , m_lineLengthLimit(4096) + , m_lineLengthLimit(100000) , m_alwaysUseKAuthForSave(alwaysUseKAuth) { // minimal block size must be > 0 diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp --- a/src/document/katedocument.cpp +++ b/src/document/katedocument.cpp @@ -2347,8 +2347,12 @@ QPointer message = new KTextEditor::Message(i18n("The file %1 was opened and contained lines longer than the configured Line Length Limit (%2 characters).
" "The longest of those lines was %3 characters long
" - "Those lines were wrapped and the document is set to read-only mode, as saving will modify its content.", - this->url().toDisplayString(QUrl::PreferLocalFile), config()->lineLengthLimit(), m_buffer->longestLineLoaded()), + "Those lines were wrapped and the document is set to read-only mode, as saving will modify its content.
" + "
Note: Highlighting is disabled on a line after %4 characters, for performance reasons.", + this->url().toDisplayString(QUrl::PreferLocalFile), + config()->lineLengthLimit(), + m_buffer->longestLineLoaded(), + KateRenderer::maxHighlightLength()), KTextEditor::Message::Warning); QAction *increaseAndReload = new QAction(i18n("Temporarily raise limit and reload file"), message); connect(increaseAndReload, SIGNAL(triggered()), this, SLOT(openWithLineLengthLimitOverride())); @@ -2363,6 +2367,19 @@ "The longest of those lines was %3 characters long
" "Those lines were wrapped and the document is set to read-only mode, as saving will modify its content.", this->url().toDisplayString(QUrl::PreferLocalFile), config()->lineLengthLimit(),m_buffer->longestLineLoaded()); } + // warn long lines + else if (m_buffer->longestLineLoaded() > KateRenderer::maxHighlightLength()) { + QPointer message + = new KTextEditor::Message(i18n("Note: Highlighting is disabled on a line after %1 characters, for performance reasons.", + KateRenderer::maxHighlightLength()), KTextEditor::Message::Information); + message->setWordWrap(true); + message->setPosition(KTextEditor::Message::TopInView); + message->setAutoHide(5000); + message->addAction(new QAction(i18n("Close"), message), true); + + postMessage(message); + } + // // return the success diff --git a/src/render/katerenderer.h b/src/render/katerenderer.h --- a/src/render/katerenderer.h +++ b/src/render/katerenderer.h @@ -277,12 +277,19 @@ */ bool isLineRightToLeft(KateLineLayoutPtr lineLayout) const; + /** + * This function returns the maximum length a line will be highlighted. + */ + static int maxHighlightLength(); + /** * The ultimate decoration creation function. * * \param selectionsOnly return decorations for selections and/or dynamic highlighting. */ - QVector decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly = false, KateRenderRange *completionHighlight = nullptr, bool completionSelected = false) const; + QVector decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly = false, + KateRenderRange *completionHighlight = nullptr, bool completionSelected = false, + int highlightLength = maxHighlightLength()) const; // Width calculators qreal spaceWidth() const; diff --git a/src/render/katerenderer.cpp b/src/render/katerenderer.cpp --- a/src/render/katerenderer.cpp +++ b/src/render/katerenderer.cpp @@ -380,7 +380,14 @@ return false; } -QVector KateRenderer::decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly, KateRenderRange *completionHighlight, bool completionSelected) const +int KateRenderer::maxHighlightLength() +{ + return 512; +} + +QVector KateRenderer::decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly, + KateRenderRange *completionHighlight, bool completionSelected, + int highlightLength) const { QVector newHighlight; @@ -485,6 +492,9 @@ endPosition = KTextEditor::Cursor(line + 1, 0); } + if (textLine->length() > highlightLength && !selectionsOnly) { + endPosition = KTextEditor::Cursor(line, maxHighlightLength()); + } // Main iterative loop. This walks through each set of highlighting ranges, and stops each // time the highlighting changes. It then creates the corresponding QTextLayout::FormatRanges. while (currentPosition < endPosition) { diff --git a/src/utils/kateconfig.cpp b/src/utils/kateconfig.cpp --- a/src/utils/kateconfig.cpp +++ b/src/utils/kateconfig.cpp @@ -320,7 +320,7 @@ const char KEY_SWAP_DIRECTORY[] = "Swap Directory"; const char KEY_SWAP_SYNC_INTERVAL[] = "Swap Sync Interval"; const char KEY_ON_THE_FLY_SPELLCHECK[] = "On-The-Fly Spellcheck"; -const char KEY_LINE_LENGTH_LIMIT[] = "Line Length Limit"; +const char KEY_LINE_LENGTH_LIMIT[] = "Line Length Limitation"; } void KateDocumentConfig::readConfig(const KConfigGroup &config) @@ -371,7 +371,7 @@ setOnTheFlySpellCheck(config.readEntry(KEY_ON_THE_FLY_SPELLCHECK, false)); - setLineLengthLimit(config.readEntry(KEY_LINE_LENGTH_LIMIT, 4096)); + setLineLengthLimit(config.readEntry(KEY_LINE_LENGTH_LIMIT, 100000)); configEnd(); } diff --git a/src/view/kateviewhelpers.cpp b/src/view/kateviewhelpers.cpp --- a/src/view/kateviewhelpers.cpp +++ b/src/view/kateviewhelpers.cpp @@ -602,7 +602,7 @@ const Kate::TextLine &kateline = m_doc->plainKateTextLine(realLineNumber); const QVector &attributes = kateline->attributesList(); - QVector decorations = m_view->renderer()->decorationsForLine(kateline, realLineNumber); + QVector decorations = m_view->renderer()->decorationsForLine(kateline, realLineNumber, false, nullptr, false, s_lineWidth); int attributeIndex = 0; // Draw selection if it is on an empty line