From bc904c447e5ebb30aea07aaf9220b7f6c5e90263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 4 Sep 2025 00:22:46 -0300 Subject: [PATCH] Do not run the spell checker in huge files. --- src/eepp/ui/doc/textdocument.cpp | 2 +- src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp | 4 ++-- src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index d2ce58e47..591d97078 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -3416,7 +3416,7 @@ static size_t guessFileSize( const TextDocument* doc ) { Int64 maxLines = std::min( (Int64)401, (Int64)doc->linesCount() ); Int64 totalSize = 0; for ( Int64 i = 0; i < maxLines; i++ ) - totalSize += doc->line( i ).size(); + totalSize += doc->getLineLength( i ); return totalSize; } diff --git a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp index 2e32c2bbd..685c8379f 100644 --- a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp +++ b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp @@ -1393,7 +1393,7 @@ void AutoCompletePlugin::resetSignatureHelp() { } AutoCompletePlugin::SymbolsList AutoCompletePlugin::getDocumentSymbols( TextDocument* doc ) { - static constexpr auto MAX_LINE_LENGTH = EE_1KB * 10; + static constexpr auto MAX_LINE_COUNT = EE_1KB * 10; AutoCompletePlugin::SymbolsList symbols; std::shared_ptr docRef = getPluginContext()->getSplitter()->getTextDocumentRef( doc ); // acquire a doc @@ -1408,7 +1408,7 @@ AutoCompletePlugin::SymbolsList AutoCompletePlugin::getDocumentSymbols( TextDocu std::string string; for ( Int64 i = 0; i < static_cast( lineCount ); i++ ) { auto len = doc->getLineLength( i ); - if ( len == 0 || len > MAX_LINE_LENGTH ) { + if ( len == 0 || len > MAX_LINE_COUNT ) { if ( len == 0 ) // Line count must have changed lineCount = doc->linesCount(); continue; diff --git a/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp b/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp index a3a63c35d..77011a817 100644 --- a/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp +++ b/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp @@ -247,9 +247,9 @@ void SpellCheckerPlugin::update( UICodeEditor* editor ) { } void SpellCheckerPlugin::spellCheckDoc( std::shared_ptr doc ) { - if ( !mLanguagesDisabled.empty() && - mLanguagesDisabled.find( doc->getSyntaxDefinition().getLSPName() ) != - mLanguagesDisabled.end() ) + if ( ( !mLanguagesDisabled.empty() && + mLanguagesDisabled.find( doc->getSyntaxDefinition().getLSPName() ) != + mLanguagesDisabled.end() ) || doc->isHuge() ) return; ScopedOp op(