diff --git a/src/eepp/ui/doc/foldrangeservice.cpp b/src/eepp/ui/doc/foldrangeservice.cpp index b77eaea0a..882a44053 100644 --- a/src/eepp/ui/doc/foldrangeservice.cpp +++ b/src/eepp/ui/doc/foldrangeservice.cpp @@ -103,29 +103,24 @@ static std::vector findFoldingRangesIndentation( TextDocument* doc ) static std::vector findFoldingRangesMarkdown( TextDocument* doc ) { static const String codeFence( "```" ); - Clock c; // For performance logging, consistent with existing functions + Clock c; std::vector regions; auto lineCount = doc->linesCount(); - // Early return for small documents, as in other folding functions if ( lineCount <= 2 ) return regions; // Stack to track open heading sections: (line number, heading level) std::vector> sectionStack; - - // State for code blocks bool inCodeBlock = false; Int64 codeBlockStart = -1; - // Process each line for ( size_t lineIdx = 0; lineIdx < lineCount; lineIdx++ ) { const String& lineText = doc->line( lineIdx ).getText(); String::View trimmed = - String::trim( lineText.view() ); // Remove leading and trailing whitespace + String::trim( lineText.view() ); if ( inCodeBlock ) { - // Check for code block end if ( String::startsWith( trimmed, "```" ) ) { // Ensure there's content to fold between start and end if ( codeBlockStart != -1 && codeBlockStart <= static_cast( lineIdx ) - 1 ) { diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index f4100c2ba..f13534afc 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -829,7 +829,9 @@ URI TextDocument::getLoadingFileURI() const { TextDocument::LoadStatus TextDocument::loadFromFile( const std::string& path ) { mLoading = true; - if ( !FileSystem::fileExists( path ) && PackManager::instance()->isFallbackToPacksActive() ) { + bool fileExists = FileSystem::fileExists( path ); + + if ( !fileExists && PackManager::instance()->isFallbackToPacksActive() ) { std::string pathFix( path ); Pack* pack = PackManager::instance()->exists( pathFix ); if ( NULL != pack ) { @@ -838,8 +840,14 @@ TextDocument::LoadStatus TextDocument::loadFromFile( const std::string& path ) { } } - IOStreamFile file( path, "rb" ); - auto ret = loadFromStream( file, path, true ); + LoadStatus ret = LoadStatus::Failed; + if ( fileExists ) { + IOStreamFile file( path, "rb" ); + ret = loadFromStream( file, path, true ); + } else { + setDirtyUntilSave(); + } + changeFilePath( path, false ); resetSyntax(); mLoading = false; diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/xit.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/xit.cpp index c631b7748..229bc595f 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/xit.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/xit.cpp @@ -10,7 +10,7 @@ SyntaxDefinition& addXit() { .getLanguageName(); }; - return SyntaxDefinitionManager::instance()->add( + auto& sd = SyntaxDefinitionManager::instance()->add( { "[x]it!", { "%.xit$" }, @@ -54,6 +54,8 @@ SyntaxDefinition& addXit() { {} } ); + sd.setFoldRangeType( FoldRangeType::Markdown ); + return sd; } }}}} // namespace EE::UI::Doc::Language diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index f256ea6d7..f173a365a 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -3386,8 +3386,8 @@ void App::initProjectTreeView( std::string path, bool openClean ) { if ( FileSystem::fileExists( rpath ) ) { loadFileFromPath( rpath, false, nullptr, onLoaded ); - } else if ( FileSystem::fileCanWrite( path ) ) { - loadFileFromPath( path, false, nullptr, onLoaded ); + } else if ( FileSystem::fileCanWrite( folderPath ) ) { + loadFileFromPath( rpath, false, nullptr, onLoaded ); } // If we opened a new tab and the first tab is simply empty, discard it