mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-22 06:01:27 +00:00
GREAT-GRANDPARENT: This fixes a crash in parent pane selection
(cherry picked from commit 91a0d0e26d)
This commit is contained in:
@@ -1106,6 +1106,29 @@ TermControl Pane::GetLastFocusedTerminalControl()
|
||||
}
|
||||
}
|
||||
|
||||
IPaneContent Pane::GetLastFocusedContent()
|
||||
{
|
||||
if (!_IsLeaf())
|
||||
{
|
||||
if (_lastActive)
|
||||
{
|
||||
auto pane = shared_from_this();
|
||||
while (const auto p = pane->_parentChildPath.lock())
|
||||
{
|
||||
if (p->_IsLeaf())
|
||||
{
|
||||
return p->_content;
|
||||
}
|
||||
pane = p;
|
||||
}
|
||||
// We didn't find our child somehow, they might have closed under us.
|
||||
}
|
||||
return _firstChild->GetLastFocusedContent();
|
||||
}
|
||||
|
||||
return _content;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Gets the TermControl of this pane. If this Pane is not a leaf this will
|
||||
// return the nullptr;
|
||||
@@ -1246,7 +1269,11 @@ void Pane::UpdateVisuals()
|
||||
void Pane::_Focus()
|
||||
{
|
||||
_GotFocusHandlers(shared_from_this(), FocusState::Programmatic);
|
||||
_content.Focus(FocusState::Programmatic);
|
||||
if (const auto& lastContent{ GetLastFocusedContent() })
|
||||
{
|
||||
lastContent.Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1925,7 +1952,7 @@ void Pane::_SetupEntranceAnimation()
|
||||
auto child = isFirstChild ? _firstChild : _secondChild;
|
||||
auto childGrid = child->_root;
|
||||
// If we are splitting a parent pane this may be null
|
||||
auto control = child->_content.GetRoot();
|
||||
auto control = child->_content ? child->_content.GetRoot() : nullptr;
|
||||
// Build up our animation:
|
||||
// * it'll take as long as our duration (200ms)
|
||||
// * it'll change the value of our property from 0 to secondSize
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
|
||||
std::shared_ptr<Pane> GetActivePane();
|
||||
winrt::Microsoft::Terminal::Control::TermControl GetLastFocusedTerminalControl();
|
||||
winrt::TerminalApp::IPaneContent GetLastFocusedContent();
|
||||
winrt::Microsoft::Terminal::Control::TermControl GetTerminalControl() const;
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile();
|
||||
bool IsConnectionClosed() const;
|
||||
|
||||
@@ -4598,7 +4598,10 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
if (const auto& pane{ tab->GetActivePane() })
|
||||
{
|
||||
terminalBrush = pane->GetContent().BackgroundBrush();
|
||||
if (const auto& lastContent{ pane->GetLastFocusedContent() })
|
||||
{
|
||||
terminalBrush = lastContent.BackgroundBrush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user