MCPcopy Create free account
hub / github.com/SpartanJ/eepp / loadAsyncFileFromPath

Method loadAsyncFileFromPath

src/eepp/ui/tools/uicodeeditorsplitter.cpp:410–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410void 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
446std::pair<UITab*, UICodeEditor*>
447UICodeEditorSplitter::loadFileFromPathInNewTab( const std::string& path ) {

Callers 1

loadFileFromPathMethod · 0.80

Calls 6

errorFunction · 0.85
emptyMethod · 0.45
setColorSchemeMethod · 0.45
loadAsyncFromURLMethod · 0.45
onDocumentLoadedMethod · 0.45
loadAsyncFromFileMethod · 0.45

Tested by

no test coverage detected