diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 4baa6f09b..6115a4a37 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -2377,6 +2377,9 @@ int TextDocument::replaceAll( const String& text, const String& replace, const b TextRange restrictRange ) { if ( text.empty() ) return 0; + bool wasRunningTransaction = isRunningTransaction(); + if ( wasRunningTransaction ) + setRunningTransaction( true ); int count = 0; TextRange found; TextPosition startedPosition = getSelection().start(); @@ -2391,6 +2394,8 @@ int TextDocument::replaceAll( const String& text, const String& replace, const b count++; } } while ( found.isValid() && endOfDoc() != found.end() ); + if ( wasRunningTransaction ) + setRunningTransaction( false ); setSelection( startedPosition ); return count; } diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index 1cc6ff127..63f07cb01 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -246,6 +246,11 @@ UICodeEditor* UICodeEditorSplitter::createCodeEditor() { } mClient->onCodeEditorCreated( editor, doc ); + if ( mCurEditor == nullptr ) + mCurEditor = editor; + if ( mCurWidget == nullptr ) + mCurWidget = editor; + return editor; } @@ -317,6 +322,8 @@ bool UICodeEditorSplitter::loadFileFromPath( const std::string& path, UICodeEdit return false; if ( nullptr == codeEditor ) codeEditor = mCurEditor; + if ( nullptr == codeEditor && !mTabWidgets.empty() ) + codeEditor = createCodeEditorInTabWidget( mTabWidgets[0] ).second; codeEditor->setColorScheme( mColorSchemes[mCurrentColorScheme] ); bool isUrl = String::startsWith( path, "https://" ) || String::startsWith( path, "http://" ); bool ret = isUrl ? codeEditor->loadAsyncFromURL( @@ -338,6 +345,8 @@ void UICodeEditorSplitter::loadAsyncFileFromPath( return; if ( nullptr == codeEditor ) codeEditor = mCurEditor; + if ( nullptr == codeEditor && !mTabWidgets.empty() ) + codeEditor = createCodeEditorInTabWidget( mTabWidgets[0] ).second; codeEditor->setColorScheme( mColorSchemes[mCurrentColorScheme] ); bool isUrl = String::startsWith( path, "https://" ) || String::startsWith( path, "http://" ); if ( isUrl ) { @@ -360,6 +369,8 @@ void UICodeEditorSplitter::loadAsyncFileFromPath( loadFileFromPath( path, codeEditor ); if ( nullptr == codeEditor ) codeEditor = mCurEditor; + if ( nullptr == codeEditor && !mTabWidgets.empty() ) + codeEditor = createCodeEditorInTabWidget( mTabWidgets[0] ).second; if ( onLoaded ) onLoaded( codeEditor, path ); #endif diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 51aee1593..19c634706 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -2534,19 +2534,30 @@ void UICodeEditor::updateHighlightWordCache() { if ( getUISceneNode()->hasThreadPool() ) { Uint64 tag = reinterpret_cast( this ); - getUISceneNode()->getThreadPool()->removeWithTag( tag ); - getUISceneNode()->getThreadPool()->run( - [this]() { - if ( mDoc->isRunningTransaction() ) - return; - mHighlightWordProcessing = true; - mHighlightWordCache = mDoc->findAll( - mHighlightWord.escapeSequences ? String::unescape( mHighlightWord.text ) - : mHighlightWord.text, - mHighlightWord.caseSensitive, mHighlightWord.wholeWord, mHighlightWord.type, - mHighlightWord.range ); + removeActionsByTag( tag ); + runOnMainThread( + [this, tag]() { + getUISceneNode()->getThreadPool()->removeWithTag( tag ); + getUISceneNode()->getThreadPool()->run( + [this]() { + if ( mDoc->isRunningTransaction() ) + return; + Clock docSearch; + mHighlightWordProcessing = true; + mHighlightWordCache = mDoc->findAll( + mHighlightWord.escapeSequences ? String::unescape( mHighlightWord.text ) + : mHighlightWord.text, + mHighlightWord.caseSensitive, mHighlightWord.wholeWord, + mHighlightWord.type, mHighlightWord.range ); + Log::info( "Document search triggered in document: \"%s\", searched for " + "\"%s\" and took %2.f ms", + mDoc->getFilename().c_str(), + mHighlightWord.text.toUtf8().c_str(), + docSearch.getElapsedTime().asMilliseconds() ); + }, + [this]( const auto& ) { mHighlightWordProcessing = false; }, tag ); }, - [this]( const auto& ) { mHighlightWordProcessing = false; }, tag ); + Milliseconds( 0 ), tag ); } else { if ( mDoc->isRunningTransaction() ) return; diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 1d79d694d..0451e7f47 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -3124,397 +3124,397 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mUISceneNode->combineStyleSheet( panelUI, false ); const std::string baseUI = R"html( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )html"; UIIconTheme* iconTheme = UIIconTheme::New( "ecode" );