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

Code before:
    {
        if (generatedProfileIds.emplace(profile->Guid()).second)
        {
            newGeneratedProfiles = true;
        }
        else
        {
            profile->Deleted(true);
            profile->Hidden(true);
        }
    }

    if (newGeneratedProfiles)
    {
        state->GeneratedProfiles(generatedProfileIds);
    }

    return newGeneratedProfiles;
}

// Returns true if something got changed and
// the settings need to be saved to disk.
bool SettingsLoader::AddDynamicProfileFolders()
{
    // Keep track of generated folders to avoid regenerating them
    const auto& state = get_self<ApplicationState>(ApplicationState::SharedInstance());
    auto generatedFolders = state->GeneratedFolders();
    auto newGeneratedFolders = false;

    // If the SSH generator is enabled, try to create an "SSH" folder with all the generated profiles
    uint32_t ignored;
    SshHostGenerator sshGenerator;
    const hstring sshGeneratorNamespace{ sshGenerator.GetNamespace() };
    const hstring sshFolderName{ L"SSH" };
    const auto& disabledProfileSources = userSettings.globals->DisabledProfileSources();
    if (!(disabledProfileSources && disabledProfileSources.IndexOf(sshGeneratorNamespace, ignored)) && generatedFolders.emplace(sshFolderName).second)
    {
        auto matchProfilesEntry = make_self<implementation::MatchProfilesEntry>();
        matchProfilesEntry->Source(sshGeneratorNamespace);

        auto folderEntry = make_self<implementation::FolderEntry>();
        folderEntry->Name(sshFolderName);
        folderEntry->Icon(MediaResource::FromString(hstring{ sshGenerator.GetIcon() }));
        folderEntry->Inlining(FolderEntryInlining::Auto);
        folderEntry->RawEntries(winrt::single_threaded_vector<Model::NewTabMenuEntry>({ *matchProfilesEntry }));

        userSettings.globals->NewTabMenu().Append(folderEntry.as<Model::NewTabMenuEntry>());
        newGeneratedFolders = true;
    }

    if (newGeneratedFolders)

Review comment (suggestion):
```suggestion
    const auto state = get_self<ApplicationState>(ApplicationState::SharedInstance());
```

Code after:
    auto newGeneratedProfiles = false;

    for (const auto& profile : _getNonUserOriginProfiles())
    {
        if (generatedProfileIds.emplace(profile->Guid()).second)
        {
            newGeneratedProfiles = true;
        }
        else
        {
            profile->Deleted(true);
            profile->Hidden(true);
        }
    }

    if (newGeneratedProfiles)
    {
        state->GeneratedProfiles(generatedProfileIds);
    }

    return newGeneratedProfiles;
}

// Returns true if something got changed and
// the settings need to be saved to disk.
bool SettingsLoader::AddDynamicProfileFolders()
{
    // Keep track of generated folders to avoid regenerating them
    const auto state = get_self<ApplicationState>(ApplicationState::SharedInstance());

    // If the SSH generator is enabled, try to create an "SSH" folder with all the generated profiles
    if (sshProfilesGenerated && !state->SSHFolderGenerated())
    {
        SshHostGenerator sshGenerator;
        auto matchProfilesEntry = make_self<implementation::MatchProfilesEntry>();
        matchProfilesEntry->Source(hstring{ sshGenerator.GetNamespace() });

        auto folderEntry = make_self<implementation::FolderEntry>();
        folderEntry->Name(L"SSH");
        folderEntry->Icon(MediaResource::FromString(hstring{ sshGenerator.GetIcon() }));
        folderEntry->Inlining(FolderEntryInlining::Auto);
        folderEntry->RawEntries(winrt::single_threaded_vector<Model::NewTabMenuEntry>({ *matchProfilesEntry }));

        userSettings.globals->NewTabMenu().Append(folderEntry.as<Model::NewTabMenuEntry>());
        state->SSHFolderGenerated(true);
        return true;
    }
    return false;
}

bool winrt::Microsoft::Terminal::Settings::Model::implementation::SettingsLoader::RemapColorSchemeForProfile(const winrt::com_ptr<winrt::Microsoft::Terminal::Settings::Model::implementation::Profile>& profile)