| 408 | } |
| 409 | |
| 410 | void UICodeEditorSplitter::loadAsyncFileFromPath( |
| 411 | const std::string& path, UICodeEditor* codeEditor, |
| 412 | std::function<void( UICodeEditor* codeEditor, const std::string& path )> onLoaded ) { |
| 413 | if ( !mThreadPool ) { |
| 414 | Log::error( "UICodeEditorSplitter::loadAsyncFileFromPath loading file async " |
| 415 | "without thread pool." ); |
| 416 | loadFileFromPath( path ); |
| 417 | return; |
| 418 | } |
| 419 | if ( FileSystem::isDirectory( path ) ) |
| 420 | return; |
| 421 | if ( nullptr == codeEditor ) |
| 422 | codeEditor = mCurEditor; |
| 423 | if ( nullptr == codeEditor && !mTabWidgets.empty() ) |
| 424 | codeEditor = createCodeEditorInTabWidget( mTabWidgets[0] ).second; |
| 425 | codeEditor->setColorScheme( mColorSchemes[mCurrentColorScheme] ); |
| 426 | bool isUrl = String::startsWith( path, "https://" ) || String::startsWith( path, "http://" ); |
| 427 | if ( isUrl ) { |
| 428 | codeEditor->loadAsyncFromURL( |
| 429 | path, Http::Request::FieldTable(), |
| 430 | [this, codeEditor, path, onLoaded]( std::shared_ptr<TextDocument>, bool ) { |
| 431 | mClient->onDocumentLoaded( codeEditor, path ); |
| 432 | if ( onLoaded ) |
| 433 | onLoaded( codeEditor, path ); |
| 434 | } ); |
| 435 | } else { |
| 436 | codeEditor->loadAsyncFromFile( |
| 437 | path, mThreadPool, |
| 438 | [this, codeEditor, path, onLoaded]( std::shared_ptr<TextDocument>, bool ) { |
| 439 | mClient->onDocumentLoaded( codeEditor, path ); |
| 440 | if ( onLoaded ) |
| 441 | onLoaded( codeEditor, path ); |
| 442 | } ); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | std::pair<UITab*, UICodeEditor*> |
| 447 | UICodeEditorSplitter::loadFileFromPathInNewTab( const std::string& path ) { |
no test coverage detected