Skip to content

Commit 7f29e1e

Browse files
committed
More things we might need for Non-Terminal content, #997
1 parent 736a351 commit 7f29e1e

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/cascadia/TerminalApp/Pane.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,11 +2144,14 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitState
21442144
std::unique_lock lock{ _createCloseLock };
21452145

21462146
const auto& termControl{ _control.try_as<TermControl>() };
2147-
// revoke our handler - the child will take care of the control now.
2148-
termControl.ConnectionStateChanged(_connectionStateChangedToken);
2149-
_connectionStateChangedToken.value = 0;
2150-
termControl.WarningBell(_warningBellToken);
2151-
_warningBellToken.value = 0;
2147+
if (termControl)
2148+
{
2149+
// revoke our handler - the child will take care of the control now.
2150+
termControl.ConnectionStateChanged(_connectionStateChangedToken);
2151+
termControl.WarningBell(_warningBellToken);
2152+
_connectionStateChangedToken.value = 0;
2153+
_warningBellToken.value = 0;
2154+
}
21522155

21532156
// Remove our old GotFocus handler from the control. We don't what the
21542157
// control telling us that it's now focused, we want it telling its new
@@ -2584,6 +2587,15 @@ void Pane::_AdvanceSnappedDimension(const bool widthOrHeight, LayoutSizeNode& si
25842587
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
25852588
}
25862589
}
2590+
else if (_IsLeaf())
2591+
{
2592+
// If we're a leaf that didn't have a TermControl, then just increment
2593+
// by one. We have to increment by _some_ value, because this is used in
2594+
// a while() loop to find the next bigger size we can snap to. But since
2595+
// a non-terminal control doesn't really care what size it's snapped to,
2596+
// we can just say "one pixel larger is the next snap point"
2597+
sizeNode.size += 1;
2598+
}
25872599
else if (!_IsLeaf())
25882600
{
25892601
// We're a parent pane, so we have to advance dimension of our children panes. In
@@ -2877,7 +2889,9 @@ std::optional<SplitState> Pane::PreCalculateAutoSplit(const std::shared_ptr<Pane
28772889
bool Pane::ContainsReadOnly() const
28782890
{
28792891
const auto& termControl{ GetTerminalControl() };
2880-
return termControl ? termControl.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly());
2892+
return termControl ?
2893+
termControl.ReadOnly() :
2894+
(_IsLeaf() ? false : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()));
28812895
}
28822896

28832897
// Method Description:

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,10 @@ namespace winrt::TerminalApp::implementation
14381438
// the control here instead.
14391439
if (_startupState == StartupState::Initialized)
14401440
{
1441-
_GetActiveControl().Focus(FocusState::Programmatic);
1441+
if (const auto& activeControl{ _GetActiveControl() })
1442+
{
1443+
activeControl.Focus(FocusState::Programmatic);
1444+
}
14421445
}
14431446
}
14441447
CATCH_LOG();

0 commit comments

Comments
 (0)