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

Code before:
            {
                selectedItemTag = navViewItem.Tag();
            }
        }

        // We'll remove a bunch of items and iterate over it twice.
        // --> Copy it into an STL vector to simplify our code and reduce COM overhead.
        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,

Review comment (suggestion):
```suggestion
                                // remove NavViewItem pointing to a Profile
```

Code after:
            {
                selectedItemTag = navViewItem.Tag();
            }
        }

        // We'll remove a bunch of items and iterate over it twice.
        // --> Copy it into an STL vector to simplify our code and reduce COM overhead.
        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,