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

Code before:
                    }
                }
                else
                {
                    // This is a new profile, check that it meets our minimum requirements first
                    // (it must have at least a name)
                    if (profileStub.isMember(JsonKey(NameKey)))
                    {
                        auto newProfile = Profile::FromJson(profileStub);
                        // Make sure to give the new profile a source, then we add it to our list of profiles
                        // We don't make modifications to the user's settings file yet, that will happen when
                        // _AppendDynamicProfilesToUserSettings() is called later
                        newProfile->Source(source);
                        _allProfiles.Append(*newProfile);
                    }
                }
            }
        }

        if (fullFile.isMember(JsonKey(SchemesKey)))
        {
            // Now we separately get each stub that adds a color scheme
            for (const auto& schemeStub : fullFile[JsonKey(SchemesKey)])
            {
                auto matchingScheme = _FindMatchingColorScheme(schemeStub);
                if (matchingScheme)
                {
                    // We do not allow modifications to existing color schemes
                }
                else
                {
                    // This is a new color scheme, add it only if it specifies _all_ the fields
                    if (ColorScheme::ValidateColorScheme(schemeStub))
                    {
                        const auto newScheme = ColorScheme::FromJson(schemeStub);
                        _globals->AddColorScheme(*newScheme);
                    }
                }
            }
        }
    }
}

// Method Description:
// - Attempts to read the given data as a string of JSON and parse that JSON
//   into a Json::Value.
// - Will ignore leading UTF-8 BOMs.
// - Additionally, will store the parsed JSON in this object, as either our
//   _defaultSettings or our _userSettings, depending on isDefaultSettings.
// - Does _not_ apply the json onto our current settings. Callers should make
//   sure to call LayerJson to ensure the settings are applied.

Review comment (suggestion):
```suggestion
                if (_FindMatchingColorScheme(schemeStub))
```
nit

Code after:
                    auto matchingProfile = _FindMatchingProfile(profileStub);
                    if (matchingProfile)
                    {
                        // We found a matching profile, create a child of it and put the modifications there
                        // (we add a new inheritance layer)
                        auto childImpl{ matchingProfile->CreateChild() };
                        childImpl->LayerJson(profileStub);

                        // replace parent in _profiles with child
                        _allProfiles.SetAt(_FindMatchingProfileIndex(matchingProfile->ToJson()).value(), *childImpl);
                    }
                }
                else
                {
                    // This is a new profile, check that it meets our minimum requirements first
                    // (it must have at least a name)
                    if (profileStub.isMember(JsonKey(NameKey)))
                    {
                        auto newProfile = Profile::FromJson(profileStub);
                        // Make sure to give the new profile a source, then we add it to our list of profiles
                        // We don't make modifications to the user's settings file yet, that will happen when
                        // _AppendDynamicProfilesToUserSettings() is called later
                        newProfile->Source(source);
                        _allProfiles.Append(*newProfile);
                    }
                }
            }
        }

        if (fullFile.isMember(JsonKey(SchemesKey)))
        {
            // Now we separately get each stub that adds a color scheme
            for (const auto& schemeStub : fullFile[JsonKey(SchemesKey)])
            {
                if (_FindMatchingColorScheme(schemeStub))
                {
                    // We do not allow modifications to existing color schemes
                }
                else
                {
                    // This is a new color scheme, add it only if it specifies _all_ the fields
                    if (ColorScheme::ValidateColorScheme(schemeStub))
                    {
                        const auto newScheme = ColorScheme::FromJson(schemeStub);
                        _globals->AddColorScheme(*newScheme);
                    }
                }
            }
        }
    }
}