Attempt to do something weird with _GenerateStub

I was thinking maybe we have the stubs have a GUID included. I like that less though I think. That would mean that DPGs would always have the GUID generated for them, even if the DPG doesn't specify a GUID. I guess that's fine though. No DPG's _aren't_ generating names now so this shouldn't change anything.
This commit is contained in:
Mike Griese 2019-09-17 10:06:37 -05:00
parent 907ebcd5e4
commit f204b98177
2 changed files with 26 additions and 2 deletions

View file

@ -253,7 +253,7 @@ TerminalSettings Profile::CreateTerminalSettings(const std::vector<ColorScheme>&
// - a JsonObject which is an equivalent serialization of this object.
Json::Value Profile::ToJson() const
{
Json::Value root = GenerateStub();
Json::Value root = _GenerateStub(false);
///// Profile-specific settings /////
root[JsonKey(HiddenKey)] = _hidden;
@ -413,6 +413,23 @@ Json::Value Profile::DiffToJson(const Profile& other) const
// Method Description:
// - Generates a Json::Value which is a "stub" of this profile. This stub will
// have enough information that it could be layered with this profile.
// - This generated stub will _always_ include a GUID. If this profile doesn't
// have a GUID, the guid will be auto-generated.
// - See _GenerateStub for more details.
// Arguments:
// - <none>
// Return Value:
// - A json::Value with a guid, name and source (if applicable).
Json::Value Profile::GenerateStub() const
{
return _GenerateStub(true);
}
// Method Description:
// - Generates a Json::Value which is a "stub" of this profile. This stub will
// have enough information that it could be layered with this profile.
// - This generated stub might include a GUID. If generateGuid is true, and this
// profile doesn't have a GUID, the guid will be auto-generated.
// - This method is used during dynamic profile generation - if a profile is
// ever generated that didn't already exist in the user's settings, we'll add
// this stub to the user's settings file, so the user has an easy point to
@ -421,7 +438,7 @@ Json::Value Profile::DiffToJson(const Profile& other) const
// - <none>
// Return Value:
// - A json::Value with a guid, name and source (if applicable).
Json::Value Profile::GenerateStub() const
Json::Value Profile::_GenerateStub(const bool generateGuid) const
{
Json::Value stub;
@ -430,6 +447,11 @@ Json::Value Profile::GenerateStub() const
{
stub[JsonKey(GuidKey)] = winrt::to_string(Utils::GuidToString(_guid.value()));
}
else if (generateGuid)
{
const auto guid = _GenerateGuidForProfile(_name, _source);
stub[JsonKey(GuidKey)] = winrt::to_string(Utils::GuidToString(guid));
}
stub[JsonKey(NameKey)] = winrt::to_string(_name);

View file

@ -86,6 +86,8 @@ public:
static GUID GetGuidOrGenerateForJson(const Json::Value& json) noexcept;
private:
Json::Value _GenerateStub(const bool generateGuid) const;
static std::wstring EvaluateStartingDirectory(const std::wstring& directory);
static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState);