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

Method loadFileDelayed

src/tools/ecode/ecode.cpp:1865–1913  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1863}
1864
1865void App::loadFileDelayed() {
1866 if ( mFileToOpen.empty() )
1867 return;
1868
1869 auto fileAndPos = getPathAndPosition( mFileToOpen );
1870 auto tab = mSplitter->isDocumentOpen( fileAndPos.first, false, true );
1871
1872 if ( tab ) {
1873 tab->getTabWidget()->setTabSelected( tab );
1874 if ( tab->getOwnedWidget()->isType( UI_TYPE_CODEEDITOR ) ) {
1875 UICodeEditor* editor = tab->getOwnedWidget()->asType<UICodeEditor>();
1876 if ( editor->getDocument().isLoading() ) {
1877 Uint32 cb =
1878 editor->on( Event::OnDocumentLoaded, [this, fileAndPos]( const Event* event ) {
1879 if ( event->getNode()->isType( UI_TYPE_CODEEDITOR ) ) {
1880 UICodeEditor* editor = event->getNode()->asType<UICodeEditor>();
1881 editor->runOnMainThread( [this, editor, fileAndPos] {
1882 editor->goToLine( fileAndPos.second );
1883 mSplitter->addEditorPositionToNavigationHistory( editor );
1884 } );
1885 }
1886 event->getNode()->removeEventListener( event->getCallbackId() );
1887 } );
1888 // Don't listen forever if no event is received
1889 editor->runOnMainThread( [editor, cb]() { editor->removeEventListener( cb ); },
1890 Seconds( 4 ) );
1891 } else {
1892 editor->runOnMainThread( [this, editor, fileAndPos] {
1893 editor->goToLine( fileAndPos.second );
1894 mSplitter->addEditorPositionToNavigationHistory( editor );
1895 } );
1896 }
1897 }
1898 } else {
1899 loadFileFromPath( fileAndPos.first, true, nullptr,
1900 [this, fileAndPos]( UICodeEditor* editor, const std::string& ) {
1901 editor->runOnMainThread( [this, editor, fileAndPos] {
1902 editor->goToLine( fileAndPos.second );
1903 mSplitter->addEditorPositionToNavigationHistory( editor );
1904 UITab* tab = mSplitter->tabFromEditor( editor );
1905 if ( tab )
1906 tab->setTabSelected();
1907 updateEditorTabTitle( editor );
1908 } );
1909 } );
1910 }
1911
1912 mFileToOpen.clear();
1913}
1914
1915const std::string& App::getThemesPath() const {
1916 return mThemesPath;

Callers 2

editorLoadedCounterMethod · 0.80
loadProjectMethod · 0.80

Calls 15

getPathAndPositionFunction · 0.85
SecondsFunction · 0.85
isDocumentOpenMethod · 0.80
getOwnedWidgetMethod · 0.80
getDocumentMethod · 0.80
getNodeMethod · 0.80
runOnMainThreadMethod · 0.80
getCallbackIdMethod · 0.80
tabFromEditorMethod · 0.80
emptyMethod · 0.45
setTabSelectedMethod · 0.45

Tested by

no test coverage detected