| 1863 | } |
| 1864 | |
| 1865 | void 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 | |
| 1915 | const std::string& App::getThemesPath() const { |
| 1916 | return mThemesPath; |
no test coverage detected