Skip to content

Commit 2eeead8

Browse files
committed
Retain (*BUT DO NOT INDICATE*) orphaned dynamic profiles (#18188)
The original intent with dynamic profiles was that they could be uninstalled but that Terminal would remember your settings in case they ever came back. After we implemented dynamic profile _deletion_, however, we accidentally made it so that saving your settings after a dynamic profile disappeared scoured it from the planet _forever_ (since we remembered that we generated it, but now it was no longer in the settings file). This pull request implements: - Tracking for orphaned dynamic profiles Closes #14061 Closes #11510 Refs #13916 Refs #9997 Modified for 1.22. I am not including any of the UI affordances. (cherry picked from commit 90866c7) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgU1-p4 Service-Version: 1.22
1 parent b97f3c1 commit 2eeead8

File tree

7 files changed

+9
-5
lines changed

7 files changed

+9
-5
lines changed

src/cascadia/TerminalSettingsEditor/LaunchViewModel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
332332
// from menus, but still work as the startup profile for instance.
333333
for (const auto& profile : allProfiles)
334334
{
335-
if (!profile.Deleted())
335+
if (!profile.Deleted() && !profile.Orphaned() /* BACKPORT GH#18188 - DO NOT DISPLAY ORPHANED PROFILES */)
336336
{
337337
profiles.emplace_back(profile);
338338
}

src/cascadia/TerminalSettingsEditor/MainPage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
526526
// profile changes.
527527
for (const auto& profile : _settingsClone.AllProfiles())
528528
{
529-
if (!profile.Deleted())
529+
if (!profile.Deleted() && !profile.Orphaned() /* BACKPORT GH#18188 - DO NOT DISPLAY ORPHANED PROFILES */)
530530
{
531531
auto profileVM = _viewModelForProfile(profile, _settingsClone);
532532
profileVM.SetupAppearances(_colorSchemesPageVM.AllColorSchemes());

src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Model::CascadiaSettings CascadiaSettings::Copy() const
103103
for (const auto& profile : targetProfiles)
104104
{
105105
allProfiles.emplace_back(*profile);
106-
if (!profile->Hidden())
106+
if (!profile->Hidden() && !profile->Orphaned())
107107
{
108108
activeProfiles.emplace_back(*profile);
109109
}

src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1217,12 +1217,12 @@ CascadiaSettings::CascadiaSettings(SettingsLoader&& loader) :
12171217
const auto& parents = profile->Parents();
12181218
if (std::none_of(parents.begin(), parents.end(), [&](const auto& parent) { return parent->Source() == source; }))
12191219
{
1220-
continue;
1220+
profile->Orphaned(true);
12211221
}
12221222
}
12231223

12241224
allProfiles.emplace_back(*profile);
1225-
if (!profile->Hidden())
1225+
if (!profile->Hidden() && !profile->Orphaned())
12261226
{
12271227
activeProfiles.emplace_back(*profile);
12281228
}

src/cascadia/TerminalSettingsModel/Profile.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ winrt::com_ptr<Profile> Profile::CopySettings() const
103103
const auto defaultAppearance = AppearanceConfig::CopyAppearance(winrt::get_self<AppearanceConfig>(_DefaultAppearance), weakProfile);
104104

105105
profile->_Deleted = _Deleted;
106+
profile->_Orphaned = _Orphaned;
106107
profile->_Updates = _Updates;
107108
profile->_Guid = _Guid;
108109
profile->_Name = _Name;

src/cascadia/TerminalSettingsModel/Profile.h

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
115115
void Icon(const hstring& value);
116116

117117
WINRT_PROPERTY(bool, Deleted, false);
118+
WINRT_PROPERTY(bool, Orphaned, false);
118119
WINRT_PROPERTY(OriginTag, Origin, OriginTag::None);
119120
WINRT_PROPERTY(guid, Updates);
120121

src/cascadia/TerminalSettingsModel/Profile.idl

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace Microsoft.Terminal.Settings.Model
4141

4242
// True if the user explicitly removed this Profile from settings.json.
4343
Boolean Deleted { get; };
44+
// True if the user *kept* this Profile, but it disappeared from the system.
45+
Boolean Orphaned { get; };
4446

4547
// Helper for magically using a commandline for an icon for a profile
4648
// without an explicit icon.

0 commit comments

Comments
 (0)