Repository: microsoft/terminal
File: src/cascadia/TerminalApp/Pane.cpp (C++)

Code before:

    _root.ColumnDefinitions().Clear();
    _root.RowDefinitions().Clear();
    _CreateRowColDefinitions();

    _borderFirst.Child(_firstChild->GetRootElement());
    _borderSecond.Child(_secondChild->GetRootElement());

    _root.Children().Append(_borderFirst);
    _root.Children().Append(_borderSecond);

    _ApplySplitDefinitions();

    // Register event handlers on our children to handle their Close events
    _SetupChildCloseHandlers();

    _lastActive = false;

    _SetupEntranceAnimation();

    // Clear out our ID, only leaves should have IDs
    _id = {};

    // Make sure to propagate our _isDefTermSession value
    WalkTree([&](auto p) {
        p->_isDefTermSession = _isDefTermSession;
    });

    // Regardless of which child the new child is, we want to return the
    // original one first.
    if (splitType == SplitDirection::Up || splitType == SplitDirection::Left)
    {
        return { _secondChild, _firstChild };
    }
    return { _firstChild, _secondChild };
}

// Method Description:
// - Recursively attempt to "zoom" the given pane. When the pane is zoomed, it
//   won't be displayed as part of the tab tree, instead it'll take up the full
//   content of the tab. When we find the given pane, we'll need to remove it
//   from the UI tree, so that the caller can re-add it. We'll also set some
//   internal state, so the pane can display all of its borders.
// Arguments:
// - zoomedPane: This is the pane which we're attempting to zoom on.
// Return Value:
// - <none>
void Pane::Maximize(std::shared_ptr<Pane> zoomedPane)
{
    _zoomed = (zoomedPane == shared_from_this());
    _UpdateBorders();

Review comment (suggestion):
Also, don't we need to bring the value back when you close a split and the Parent becomes a Leaf again?

And like, we need to correctly handle the state when you open a DefTerm, split it, and close the DefTerm. The remaining leaf should NOT have this set to true ..

Code after:
        std::swap(_firstChild, _secondChild);
    }

    _root.ColumnDefinitions().Clear();
    _root.RowDefinitions().Clear();
    _CreateRowColDefinitions();

    _borderFirst.Child(_firstChild->GetRootElement());
    _borderSecond.Child(_secondChild->GetRootElement());

    _root.Children().Append(_borderFirst);
    _root.Children().Append(_borderSecond);

    _ApplySplitDefinitions();

    // Register event handlers on our children to handle their Close events
    _SetupChildCloseHandlers();

    _lastActive = false;

    _SetupEntranceAnimation();

    // Clear out our ID, only leaves should have IDs
    _id = {};

    // Regardless of which child the new child is, we want to return the
    // original one first.
    if (splitType == SplitDirection::Up || splitType == SplitDirection::Left)
    {
        return { _secondChild, _firstChild };
    }
    return { _firstChild, _secondChild };
}

// Method Description:
// - Recursively attempt to "zoom" the given pane. When the pane is zoomed, it
//   won't be displayed as part of the tab tree, instead it'll take up the full
//   content of the tab. When we find the given pane, we'll need to remove it
//   from the UI tree, so that the caller can re-add it. We'll also set some
//   internal state, so the pane can display all of its borders.
// Arguments:
// - zoomedPane: This is the pane which we're attempting to zoom on.
// Return Value:
// - <none>
void Pane::Maximize(std::shared_ptr<Pane> zoomedPane)
{
    _zoomed = (zoomedPane == shared_from_this());
    _UpdateBorders();
    if (!_IsLeaf())
    {
        if (zoomedPane == _firstChild || zoomedPane == _secondChild)