Fix persistence of empty windows (#18622)

This is a theoretical fix for #18584 as I cannot reproduce the issue
anymore. It did happen briefly on one of my devices though, and at the
time I observed that it would persist a window with no startup actions.

(cherry picked from commit 265d8415094f41e161c2287aa80876b82d809c0c)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgXpj1U
Service-Version: 1.23
This commit is contained in:
Leonard Hecker 2025-02-24 10:27:45 -08:00 committed by Dustin L. Howett
parent 2590ff1383
commit a72531014c

View File

@ -1988,6 +1988,12 @@ namespace winrt::TerminalApp::implementation
actions.insert(actions.end(), std::make_move_iterator(tabActions.begin()), std::make_move_iterator(tabActions.end()));
}
// Avoid persisting a window with zero tabs, because `BuildStartupActions` happened to return an empty vector.
if (actions.empty())
{
return;
}
// if the focused tab was not the last tab, restore that
auto idx = _GetFocusedTabIndex();
if (idx && idx != tabCount - 1)