From 19230cc2fb103c99f01fce73d2ba52443ce82f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 17 Feb 2026 21:46:10 -0300 Subject: [PATCH] Fix a focusing issue when moving a terminal to the status bar terminal, hiding the terminal would not focus any editor. --- src/eepp/ui/tools/uicodeeditorsplitter.cpp | 13 +++++++++++++ src/tools/ecode/terminalmanager.cpp | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index ae5657a46..eec4c48b6 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -517,6 +517,19 @@ void UICodeEditorSplitter::setCurrentEditor( UICodeEditor* editor ) { } void UICodeEditorSplitter::setCurrentWidget( UIWidget* curWidget ) { + if ( curWidget == nullptr ) { + if ( mCurEditor ) { + mCurWidget = mCurEditor; + mClient->onWidgetFocusChange( curWidget ); + } else { + // Should never happen: curWidget == nullptr is passed when a terminal is moved outside + // the splitter + auto editor = getSomeEditor(); + if ( editor ) + setCurrentWidget( editor ); + } + return; + } if ( curWidget->isType( UI_TYPE_CODEEDITOR ) ) { setCurrentEditor( curWidget->asType() ); return; diff --git a/src/tools/ecode/terminalmanager.cpp b/src/tools/ecode/terminalmanager.cpp index 8302e2bb3..b38e398a6 100644 --- a/src/tools/ecode/terminalmanager.cpp +++ b/src/tools/ecode/terminalmanager.cpp @@ -555,6 +555,11 @@ UITerminal* TerminalManager::createNewTerminal( ret.first->setIcon( mApp->findIcon( "filetype-bash" ) ); mApp->getSplitter()->removeUnusedTab( tabWidget, true, false ); + term->removeEventsOfType( Event::OnFocus ); + term->on( Event::OnFocus, [this, term]( const Event* ) { + mApp->getSplitter()->setCurrentWidget( + mApp->getSplitter()->getBaseLayout()->inParentTreeOf( term ) ? term : nullptr ); + } ); term->setTitle( title ); auto csIt = mTerminalColorSchemes.find( mTerminalCurrentColorScheme ); term->getTerm()->getTerminal()->setAllowMemoryTrimnming( true );