File tree 3 files changed +34
-3
lines changed
3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -1106,6 +1106,29 @@ TermControl Pane::GetLastFocusedTerminalControl()
1106
1106
}
1107
1107
}
1108
1108
1109
+ IPaneContent Pane::GetLastFocusedContent ()
1110
+ {
1111
+ if (!_IsLeaf ())
1112
+ {
1113
+ if (_lastActive)
1114
+ {
1115
+ auto pane = shared_from_this ();
1116
+ while (const auto p = pane->_parentChildPath .lock ())
1117
+ {
1118
+ if (p->_IsLeaf ())
1119
+ {
1120
+ return p->_content ;
1121
+ }
1122
+ pane = p;
1123
+ }
1124
+ // We didn't find our child somehow, they might have closed under us.
1125
+ }
1126
+ return _firstChild->GetLastFocusedContent ();
1127
+ }
1128
+
1129
+ return _content;
1130
+ }
1131
+
1109
1132
// Method Description:
1110
1133
// - Gets the TermControl of this pane. If this Pane is not a leaf this will
1111
1134
// return the nullptr;
@@ -1246,7 +1269,11 @@ void Pane::UpdateVisuals()
1246
1269
void Pane::_Focus ()
1247
1270
{
1248
1271
_GotFocusHandlers (shared_from_this (), FocusState::Programmatic);
1249
- _content.Focus (FocusState::Programmatic);
1272
+ if (const auto & lastContent{ GetLastFocusedContent () })
1273
+ {
1274
+ lastContent.Focus (FocusState::Programmatic);
1275
+ }
1276
+
1250
1277
}
1251
1278
1252
1279
// Method Description:
@@ -1925,7 +1952,7 @@ void Pane::_SetupEntranceAnimation()
1925
1952
auto child = isFirstChild ? _firstChild : _secondChild;
1926
1953
auto childGrid = child->_root ;
1927
1954
// If we are splitting a parent pane this may be null
1928
- auto control = child->_content .GetRoot ();
1955
+ auto control = child->_content ? child-> _content .GetRoot () : nullptr ;
1929
1956
// Build up our animation:
1930
1957
// * it'll take as long as our duration (200ms)
1931
1958
// * it'll change the value of our property from 0 to secondSize
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class Pane : public std::enable_shared_from_this<Pane>
73
73
74
74
std::shared_ptr<Pane> GetActivePane ();
75
75
winrt::Microsoft::Terminal::Control::TermControl GetLastFocusedTerminalControl ();
76
+ winrt::TerminalApp::IPaneContent GetLastFocusedContent ();
76
77
winrt::Microsoft::Terminal::Control::TermControl GetTerminalControl () const ;
77
78
winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile ();
78
79
bool IsConnectionClosed () const ;
Original file line number Diff line number Diff line change @@ -4598,7 +4598,10 @@ namespace winrt::TerminalApp::implementation
4598
4598
{
4599
4599
if (const auto & pane{ tab->GetActivePane () })
4600
4600
{
4601
- terminalBrush = pane->GetContent ().BackgroundBrush ();
4601
+ if (const auto & lastContent{ pane->GetLastFocusedContent () })
4602
+ {
4603
+ terminalBrush = lastContent.BackgroundBrush ();
4604
+ }
4602
4605
}
4603
4606
}
4604
4607
You can’t perform that action at this time.
0 commit comments