| 524 | } |
| 525 | |
| 526 | bool UICodeEditor::loadAsyncFromFile( |
| 527 | const std::string& path, std::shared_ptr<ThreadPool> pool, |
| 528 | std::function<void( std::shared_ptr<TextDocument>, bool )> onLoaded ) { |
| 529 | bool wasLocked = isLocked(); |
| 530 | if ( !wasLocked ) |
| 531 | setLocked( true ); |
| 532 | bool ret = mDoc->loadAsyncFromFile( |
| 533 | path, pool, [this, onLoaded, wasLocked]( TextDocument*, bool success ) { |
| 534 | if ( !success ) { |
| 535 | runOnMainThread( [this, onLoaded, wasLocked, success] { |
| 536 | if ( !wasLocked ) |
| 537 | setLocked( false ); |
| 538 | if ( onLoaded ) |
| 539 | onLoaded( mDoc, success ); |
| 540 | } ); |
| 541 | return; |
| 542 | } |
| 543 | if ( mMinimapEnabled && getUISceneNode()->hasThreadPool() ) { |
| 544 | mDoc->getHighlighter()->tokenizeAsync( getUISceneNode()->getThreadPool(), [this] { |
| 545 | runOnMainThread( [this] { invalidateDraw(); } ); |
| 546 | } ); |
| 547 | } |
| 548 | |
| 549 | if ( mDocView.isWrapEnabled() ) |
| 550 | mDocView.setPendingReconstruction( true ); |
| 551 | |
| 552 | runOnMainThread( [this, onLoaded, wasLocked, success] { |
| 553 | if ( !wasLocked ) |
| 554 | setLocked( false ); |
| 555 | onDocumentLoaded(); |
| 556 | if ( onLoaded ) |
| 557 | onLoaded( mDoc, success ); |
| 558 | } ); |
| 559 | } ); |
| 560 | if ( !ret && !wasLocked ) |
| 561 | setLocked( false ); |
| 562 | return ret; |
| 563 | } |
| 564 | |
| 565 | TextDocument::LoadStatus UICodeEditor::loadFromURL( const std::string& url, |
| 566 | const Http::Request::FieldTable& headers ) { |
nothing calls this directly
no test coverage detected