Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp (C++)

Code before:
    auto json = _parseJson(content);

    settings.clear();

    {
        settings.globals = winrt::make_self<GlobalAppSettings>();

        for (const auto& schemeJson : json.colorSchemes)
        {
            try
            {
                if (const auto scheme = ColorScheme::FromJson(schemeJson))
                {
                    settings.globals->AddColorScheme(*scheme);
                }
            }
            CATCH_LOG()
        }

        // Construct a temp Json::Value that contains ONLY the actions from the
        // fragment. This will allow fragments to add actions, but not
        // necessarily set other global properties.
        Json::Value tmp = {};
        tmp[ActionsKey.data()] = json.root[ActionsKey.data()];

        // Now parse that tmep json object, as if it were a global settings
        // blob. Manually opt-out of keybinding parsing - fragments shouldn't be
        // allowed to bind actions to keys directly. We may want to revisit
        // circa GH#2205
        settings.globals->LayerJson(tmp, false);
    }

    {
        const auto size = json.profilesList.size();
        settings.profiles.reserve(size);
        settings.profilesByGuid.reserve(size);

        for (const auto& profileJson : json.profilesList)
        {
            try
            {
                auto profile = _parseProfile(OriginTag::Fragment, source, profileJson);
                // GH#9962: Discard Guid-less, Name-less profiles, but...
                // allow ones with an Updates field, as those are special for fragments.
                // We need to make sure to only call Guid() if HasGuid() is true,
                // as Guid() will dynamically generate a return value otherwise.
                const auto guid = profile->HasGuid() ? profile->Guid() : profile->Updates();
                if (guid != winrt::guid{})
                {
                    _appendProfile(std::move(profile), guid, settings);
                }

Review comment (suggestion):
```suggestion
        // Now parse that temp json object, as if it were a global settings
```

Code after:

    settings.clear();

    {
        settings.globals = winrt::make_self<GlobalAppSettings>();

        for (const auto& schemeJson : json.colorSchemes)
        {
            try
            {
                if (const auto scheme = ColorScheme::FromJson(schemeJson))
                {
                    settings.globals->AddColorScheme(*scheme);
                }
            }
            CATCH_LOG()
        }

        // Parse out actions from the fragment. Manually opt-out of keybinding
        // parsing - fragments shouldn't be allowed to bind actions to keys
        // directly. We may want to revisit circa GH#2205
        settings.globals->LayerActionsFrom(json.root, false);
    }

    {
        const auto size = json.profilesList.size();
        settings.profiles.reserve(size);
        settings.profilesByGuid.reserve(size);

        for (const auto& profileJson : json.profilesList)
        {
            try
            {
                auto profile = _parseProfile(OriginTag::Fragment, source, profileJson);
                // GH#9962: Discard Guid-less, Name-less profiles, but...
                // allow ones with an Updates field, as those are special for fragments.
                // We need to make sure to only call Guid() if HasGuid() is true,
                // as Guid() will dynamically generate a return value otherwise.
                const auto guid = profile->HasGuid() ? profile->Guid() : profile->Updates();
                if (guid != winrt::guid{})
                {
                    _appendProfile(std::move(profile), guid, settings);
                }
            }
            CATCH_LOG()
        }
    }

    for (const auto& fragmentProfile : settings.profiles)
    {
        if (const auto updates = fragmentProfile->Updates(); updates != winrt::guid{})