Skip to content

Commit

Permalink
Don't explode when we tear out the last tab of the window (#15259)
Browse files Browse the repository at this point in the history
If you were really fast, and closed one window, and then tried to drag
the only tab out of the last remaining window, the Terminal could
explode. It'd attempt to restore the previous window state, and explode.

Easy way to stop this (also, be more robust): just don't attempt to
restore windows during tear-out. That's obvious.

This is a part of #14957
  • Loading branch information
zadjii-msft authored Apr 28, 2023
1 parent c4944c3 commit 97a617a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window
if (_peasant)
{
const auto& args{ _peasant.InitialArgs() };

if (!windowArgs.Content().empty())
const bool startedForContent = !windowArgs.Content().empty();
if (startedForContent)
{
_windowLogic.SetStartupContent(windowArgs.Content(), windowArgs.InitialBounds());
}
Expand Down Expand Up @@ -220,7 +220,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window
// seemed to reorder bits of init so much that everything broke. So
// we'll leave it here.
const auto numPeasants = _windowManager.GetNumberOfPeasants();
if (numPeasants == 1)
// Don't attempt to session restore if we're just making a window for tear-out
if (!startedForContent && numPeasants == 1)
{
const auto layouts = ApplicationState::SharedInstance().PersistedWindowLayouts();
if (_appLogic.ShouldUsePersistedLayout() &&
Expand Down

0 comments on commit 97a617a

Please sign in to comment.