Skip to content

Commit 69fc2d9

Browse files
authored
Clean up persisted windows after the feature is disabled (#18910)
I finally realized the missing piece. We need to clear the state array unconditionally, as otherwise it won't get cleared. Duh. Closes #18584 ## Validation Steps Performed * Craft a state.json with a layout * Launch Terminal while the feature is disabled * state.json is cleaned up on exit ✅
1 parent 14993db commit 69fc2d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cascadia/WindowsTerminal/WindowEmperor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,9 +925,15 @@ void WindowEmperor::_finalizeSessionPersistence() const
925925
{
926926
const auto state = ApplicationState::SharedInstance();
927927

928-
if (_forcePersistence || _app.Logic().Settings().GlobalSettings().ShouldUsePersistedLayout())
928+
// Calling an `ApplicationState` setter triggers a write to state.json.
929+
// With this if condition we avoid an unnecessary write when persistence is disabled.
930+
if (state.PersistedWindowLayouts())
929931
{
930932
state.PersistedWindowLayouts(nullptr);
933+
}
934+
935+
if (_forcePersistence || _app.Logic().Settings().GlobalSettings().ShouldUsePersistedLayout())
936+
{
931937
for (const auto& w : _windows)
932938
{
933939
w->Logic().PersistState();

0 commit comments

Comments
 (0)