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 @@ -1340,6 +1340,29 @@ TermControl Pane::GetLastFocusedTerminalControl()
1340
1340
}
1341
1341
}
1342
1342
1343
+ IPaneContent Pane::GetLastFocusedContent ()
1344
+ {
1345
+ if (!_IsLeaf ())
1346
+ {
1347
+ if (_lastActive)
1348
+ {
1349
+ auto pane = shared_from_this ();
1350
+ while (const auto p = pane->_parentChildPath .lock ())
1351
+ {
1352
+ if (p->_IsLeaf ())
1353
+ {
1354
+ return p->_content ;
1355
+ }
1356
+ pane = p;
1357
+ }
1358
+ // We didn't find our child somehow, they might have closed under us.
1359
+ }
1360
+ return _firstChild->GetLastFocusedContent ();
1361
+ }
1362
+
1363
+ return _content;
1364
+ }
1365
+
1343
1366
// Method Description:
1344
1367
// - Gets the TermControl of this pane. If this Pane is not a leaf this will
1345
1368
// return the nullptr;
@@ -1480,7 +1503,11 @@ void Pane::UpdateVisuals()
1480
1503
void Pane::_Focus ()
1481
1504
{
1482
1505
_GotFocusHandlers (shared_from_this (), FocusState::Programmatic);
1483
- _content.Focus (FocusState::Programmatic);
1506
+ if (const auto & lastContent{ GetLastFocusedContent () })
1507
+ {
1508
+ lastContent.Focus (FocusState::Programmatic);
1509
+ }
1510
+
1484
1511
}
1485
1512
1486
1513
// Method Description:
@@ -2176,7 +2203,7 @@ void Pane::_SetupEntranceAnimation()
2176
2203
auto child = isFirstChild ? _firstChild : _secondChild;
2177
2204
auto childGrid = child->_root ;
2178
2205
// If we are splitting a parent pane this may be null
2179
- auto control = child->_content .GetRoot ();
2206
+ auto control = child->_content ? child-> _content .GetRoot () : nullptr ;
2180
2207
// Build up our animation:
2181
2208
// * it'll take as long as our duration (200ms)
2182
2209
// * 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