Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/MainPage.cpp (C++)

Code before:
        std::vector<IInspectable> menuItemsSTL(menuItems.Size(), nullptr);
        menuItems.GetMany(0, menuItemsSTL);

        // We want to refresh the list of profiles in the NavigationView.
        // In order to add profiles we can use _InitializeProfilesList();
        // But before we can do that we have to remove existing profiles first of course.
        // This "erase-remove" idiom will achieve just that.
        menuItemsSTL.erase(
            std::remove_if(
                menuItemsSTL.begin(),
                menuItemsSTL.end(),
                [](const auto& item) -> bool {
                    if (const auto& navViewItem{ item.try_as<MUX::Controls::NavigationViewItem>() })
                    {
                        if (const auto& tag{ navViewItem.Tag() })
                        {
                            if (tag.try_as<Editor::ProfileViewModel>())
                            {
                                // don't add NavViewItem pointing to a Profile
                                return true;
                            }
                            if (const auto& stringTag{ tag.try_as<hstring>() })
                            {
                                if (stringTag == addProfileTag)
                                {
                                    // don't add the "Add Profile" item
                                    return true;
                                }
                            }
                        }
                    }
                    return false;
                }),
            menuItemsSTL.end());

        menuItems.ReplaceAll(menuItemsSTL);

        // Repopulate profile-related menu items
        _InitializeProfilesList();
        // Update the Nav State with the new version of the settings
        _colorSchemesNavState.Settings(_settingsClone);
        // We'll update the profile in the _profilesNavState whenever we actually navigate to one

        // now that the menuItems are repopulated,
        // refresh the current page using the SelectedItem data we collected before the refresh
        if (selectedItemTag)
        {
            for (const auto& item : menuItemsSTL)
            {
                if (const auto& menuItem{ item.try_as<MUX::Controls::NavigationViewItem>() })
                {

Review comment (suggestion):
```suggestion
                                    // remove the "Add Profile" item
```

Code after:
        std::vector<IInspectable> menuItemsSTL(menuItems.Size(), nullptr);
        menuItems.GetMany(0, menuItemsSTL);

        // We want to refresh the list of profiles in the NavigationView.
        // In order to add profiles we can use _InitializeProfilesList();
        // But before we can do that we have to remove existing profiles first of course.
        // This "erase-remove" idiom will achieve just that.
        menuItemsSTL.erase(
            std::remove_if(
                menuItemsSTL.begin(),
                menuItemsSTL.end(),
                [](const auto& item) -> bool {
                    if (const auto& navViewItem{ item.try_as<MUX::Controls::NavigationViewItem>() })
                    {
                        if (const auto& tag{ navViewItem.Tag() })
                        {
                            if (tag.try_as<Editor::ProfileViewModel>())
                            {
                                // remove NavViewItem pointing to a Profile
                                return true;
                            }
                            if (const auto& stringTag{ tag.try_as<hstring>() })
                            {
                                if (stringTag == addProfileTag)
                                {
                                    // remove the "Add Profile" item
                                    return true;
                                }
                            }
                        }
                    }
                    return false;
                }),
            menuItemsSTL.end());

        menuItems.ReplaceAll(menuItemsSTL);

        // Repopulate profile-related menu items
        _InitializeProfilesList();
        // Update the Nav State with the new version of the settings
        _colorSchemesNavState.Settings(_settingsClone);
        // We'll update the profile in the _profilesNavState whenever we actually navigate to one

        // now that the menuItems are repopulated,
        // refresh the current page using the SelectedItem data we collected before the refresh
        if (selectedItemTag)
        {
            for (const auto& item : menuItemsSTL)
            {
                if (const auto& menuItem{ item.try_as<MUX::Controls::NavigationViewItem>() })
                {