Skip to content

Commit 0c98216

Browse files
committed
[<= 1.22] Retain (BUT DON'T INDICATE) orphaned dynamic profiles (#18206)
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 (cherry picked from commit 2143ca1) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgU2frw Service-Version: 1.21
1 parent ca6af92 commit 0c98216

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
@@ -525,7 +525,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
525525
// profile changes.
526526
for (const auto& profile : _settingsClone.AllProfiles())
527527
{
528-
if (!profile.Deleted())
528+
if (!profile.Deleted() && !profile.Orphaned() /* BACKPORT GH#18188 - DO NOT DISPLAY ORPHANED PROFILES */)
529529
{
530530
auto profileVM = _viewModelForProfile(profile, _settingsClone);
531531
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
@@ -1208,12 +1208,12 @@ CascadiaSettings::CascadiaSettings(SettingsLoader&& loader) :
12081208
const auto& parents = profile->Parents();
12091209
if (std::none_of(parents.begin(), parents.end(), [&](const auto& parent) { return parent->Source() == source; }))
12101210
{
1211-
continue;
1211+
profile->Orphaned(true);
12121212
}
12131213
}
12141214

12151215
allProfiles.emplace_back(*profile);
1216-
if (!profile->Hidden())
1216+
if (!profile->Hidden() && !profile->Orphaned())
12171217
{
12181218
activeProfiles.emplace_back(*profile);
12191219
}

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
@@ -113,6 +113,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
113113
void Icon(const hstring& value);
114114

115115
WINRT_PROPERTY(bool, Deleted, false);
116+
WINRT_PROPERTY(bool, Orphaned, false);
116117
WINRT_PROPERTY(OriginTag, Origin, OriginTag::None);
117118
WINRT_PROPERTY(guid, Updates);
118119

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)