Skip to content

Commit

Permalink
Bugfix: layering would erase values when it couldn't find anything
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Aug 18, 2020
1 parent bdd7430 commit 03f6231
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions src/cascadia/TerminalApp/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,24 +317,39 @@ bool Profile::ShouldBeLayered(const Json::Value& json) const
// <none>
void Profile::LayerJson(const Json::Value& json)
{
std::optional<GUID> guid;
std::optional<til::color> color;
std::optional<GUID> guid = std::nullopt;
std::optional<til::color> color = std::nullopt;

// Profile-specific Settings
JsonUtils::GetValueForKey(json, NameKey, _Name);
JsonUtils::GetValueForKey(json, GuidKey, guid);
_Guid = guid.has_value() ? IReference<winrt::guid>{ guid.value() } : nullptr;
if (JsonUtils::GetValueForKey(json, GuidKey, guid))
{
_Guid = guid.has_value() ? IReference<winrt::guid>{ guid.value() } : nullptr;
guid.reset();
}
JsonUtils::GetValueForKey(json, HiddenKey, _Hidden);

// Core Settings
JsonUtils::GetValueForKey(json, ForegroundKey, color);
_Foreground = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
JsonUtils::GetValueForKey(json, BackgroundKey, color);
_Background = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
JsonUtils::GetValueForKey(json, SelectionBackgroundKey, color);
_SelectionBackground = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
JsonUtils::GetValueForKey(json, CursorColorKey, color);
_CursorColor = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
if (JsonUtils::GetValueForKey(json, ForegroundKey, color))
{
_Foreground = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
color.reset();
}
if (JsonUtils::GetValueForKey(json, BackgroundKey, color))
{
_Background = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
color.reset();
}
if (JsonUtils::GetValueForKey(json, SelectionBackgroundKey, color))
{
_SelectionBackground = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
color.reset();
}
if (JsonUtils::GetValueForKey(json, CursorColorKey, color))
{
_CursorColor = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
color.reset();
}
JsonUtils::GetValueForKey(json, ColorSchemeKey, _ColorSchemeName);

// TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback"
Expand All @@ -347,8 +362,11 @@ void Profile::LayerJson(const Json::Value& json)

// Control Settings
JsonUtils::GetValueForKey(json, FontWeightKey, _FontWeight);
JsonUtils::GetValueForKey(json, ConnectionTypeKey, guid);
_ConnectionType = guid.has_value() ? IReference<winrt::guid>{ guid.value() } : nullptr;
if (JsonUtils::GetValueForKey(json, ConnectionTypeKey, guid))
{
_ConnectionType = guid.has_value() ? IReference<winrt::guid>{ guid.value() } : nullptr;
guid.reset();
}
JsonUtils::GetValueForKey(json, CommandlineKey, _Commandline);
JsonUtils::GetValueForKey(json, FontFaceKey, _FontFace);
JsonUtils::GetValueForKey(json, FontSizeKey, _FontSize);
Expand All @@ -371,8 +389,11 @@ void Profile::LayerJson(const Json::Value& json)
JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect);
JsonUtils::GetValueForKey(json, AntialiasingModeKey, _AntialiasingMode);

JsonUtils::GetValueForKey(json, TabColorKey, color);
_TabColor = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
if (JsonUtils::GetValueForKey(json, TabColorKey, color))
{
_TabColor = color.has_value() ? IReference<Color>{ color.value() } : nullptr;
color.reset();
}
}

// Method Description:
Expand Down

0 comments on commit 03f6231

Please sign in to comment.