Skip to content

Commit

Permalink
Don't explode on session restore (#16998)
Browse files Browse the repository at this point in the history
As noted in #16995. 

Don't persist us if we weren't ever initialized. In that case, we
never got an initial size, never instantiated a buffer, and didn't
start the connection yet, so there's nothing for us to add here.

If we were supposed to be restored from a path, then we don't need to
do anything special here. We'll leave the original file untouched,
and the next time we actually are initialized, we'll just use that
file then.

Closes #16995
  • Loading branch information
zadjii-msft authored Apr 2, 2024
1 parent ad0b672 commit 5f10159
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation

void TermControl::PersistToPath(const winrt::hstring& path) const
{
winrt::get_self<ControlCore>(_core)->PersistToPath(path.c_str());
// Don't persist us if we weren't ever initialized. In that case, we
// never got an initial size, never instantiated a buffer, and didn't
// start the connection yet, so there's nothing for us to add here.
//
// If we were supposed to be restored from a path, then we don't need to
// do anything special here. We'll leave the original file untouched,
// and the next time we actually are initialized, we'll just use that
// file then.
if (_initializedTerminal)
{
winrt::get_self<ControlCore>(_core)->PersistToPath(path.c_str());
}
}

void TermControl::Close()
Expand Down

0 comments on commit 5f10159

Please sign in to comment.