Skip to content

Commit

Permalink
Serialize 'disabledProfileSources' (#9038)
Browse files Browse the repository at this point in the history
"disabledProfileSources" is saved to `CascadiaSettings` _not_
`GlobalAppSettings` (and, even then, it's only read when it's used,
never saved). This PR specifically detects if it was defined in
settings.json, and copies it over when the settings are serialized.

## Validation Steps Performed
1. Added "disabledProfileSources" to settings.json, then serialized. -->
   "disabledProfileSources" is now maintained.
2. Updated `CascadiaSettings` serialization test

Closes #9032

(cherry picked from commit 230fad5)
  • Loading branch information
carlos-zamora authored and DHowett committed Feb 5, 2021
1 parent b80f6de commit 9444617
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ namespace SettingsModelLocalTests
const std::string settingsString{ R"({
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-1111-5271-96e7-009a87ff44bf}",
"disabledProfileSources": [ "Windows.Terminal.Wsl" ],
"profiles": {
"defaults": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,13 @@ void CascadiaSettings::WriteSettingsToDisk() const
Json::Value CascadiaSettings::ToJson() const
{
// top-level json object
// directly inject "globals" and "$schema" into here
// directly inject "globals", "$schema", and "disabledProfileSources" into here
Json::Value json{ _globals->ToJson() };
JsonUtils::SetValueForKey(json, SchemaKey, JsonKey(SchemaValue));
if (_userSettings.isMember(JsonKey(DisabledProfileSourcesKey)))
{
json[JsonKey(DisabledProfileSourcesKey)] = _userSettings[JsonKey(DisabledProfileSourcesKey)];
}

// "profiles" will always be serialized as an object
Json::Value profiles{ Json::ValueType::objectValue };
Expand Down

0 comments on commit 9444617

Please sign in to comment.