diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index 83bd53308..5fbda8fc6 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -531,10 +531,19 @@ void AppConfig::loadDocuments( UICodeEditorSplitter* editorSplitter, json j, for ( const auto& file : j["files"] ) { if ( !file.contains( "type" ) || file["type"] == "editor" ) { std::string path( file["path"] ); - if ( !FileSystem::fileExists( path ) ) { + auto snapshotSaveIt = std::find_if( + sessionSnapshotFiles.begin(), sessionSnapshotFiles.end(), + [&path]( const SessionSnapshotFile& file ) { return file.fspath == path; } ); + + SessionSnapshotFile snapshotFile; + if ( snapshotSaveIt != sessionSnapshotFiles.end() ) + snapshotFile = *snapshotSaveIt; + + if ( !FileSystem::fileExists( path ) && snapshotFile.cachePath.empty() ) { editorLoadedCounter( app ); continue; } + TextRanges selection( TextRanges::fromString( file["selection"] ) ); UITab* tab = nullptr; if ( ( tab = editorSplitter->isDocumentOpen( path, false, true ) ) != nullptr ) { @@ -555,17 +564,6 @@ void AppConfig::loadDocuments( UICodeEditorSplitter* editorSplitter, json j, editorLoadedCounter( app ); } else { - auto snapshotSaveIt = - std::find_if( sessionSnapshotFiles.begin(), sessionSnapshotFiles.end(), - [&path]( const SessionSnapshotFile& file ) { - return file.fspath == path; - } ); - - std::string loadPath( path ); - SessionSnapshotFile snapshotFile; - if ( snapshotSaveIt != sessionSnapshotFiles.end() ) - snapshotFile = *snapshotSaveIt; - editorSplitter->loadAsyncFileFromPathInNewTab( path, [this, curTabWidget, selection, totalToLoad, currentPage, app, path, @@ -592,8 +590,12 @@ void AppConfig::loadDocuments( UICodeEditorSplitter* editorSplitter, json j, doc.resetUndoRedo(); doc.setDirtyUntilSave(); editor->scrollToCursor(); - if ( diskFileInfo.getModificationTime() > snapshotFile.fsmtime ) + if ( !FileSystem::fileExists( path ) ) { + app->createDocDoesNotExistsInFSAlert( editor ); + } else if ( diskFileInfo.getModificationTime() > + snapshotFile.fsmtime ) { app->createDocDirtyAlert( editor, false ); + } } editorLoadedCounter( app ); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 218486c0c..5decfbb7b 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2361,6 +2361,48 @@ void App::createDocDirtyAlert( UICodeEditor* editor, bool showEnableAutoReload ) Seconds( 30.f ) ); } +void App::createDocDoesNotExistsInFSAlert( UICodeEditor* editor ) { + UILinearLayout* docAlert = editor->findByClass( "doc_alert" ); + + if ( docAlert ) + return; + + const auto msg = R"xml( + + + + + + )xml"; + docAlert = mUISceneNode->loadLayoutFromString( msg, editor )->asType(); + + editor->enableReportSizeChangeToChilds(); + + docAlert->find( "file_continue_editing" )->onClick( [docAlert, editor]( const MouseEvent* ) { + editor->disableReportSizeChangeToChilds(); + docAlert->close(); + editor->setFocus(); + } ); + + docAlert->find( "file_close" )->onClick( [this, editor, docAlert]( const MouseEvent* ) { + editor->disableReportSizeChangeToChilds(); + docAlert->close(); + mSplitter->closeTab( editor, UITabWidget::FocusTabBehavior::Default ); + } ); + + docAlert->runOnMainThread( + [docAlert, editor] { + editor->disableReportSizeChangeToChilds(); + docAlert->close(); + editor->setFocus(); + }, + Seconds( 30.f ) ); +} + void App::createDocManyLangsAlert( UICodeEditor* editor ) { UILinearLayout* docAlert = editor->findByClass( "doc_alert_manylangs" ); diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 254b0870d..738435159 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -469,6 +469,8 @@ class App : public UICodeEditorSplitter::Client { void createDocDirtyAlert( UICodeEditor* editor, bool showEnableAutoReload = true ); + void createDocDoesNotExistsInFSAlert( UICodeEditor* editor ); + protected: std::vector mArgs; EE::Window::Window* mWindow{ nullptr };