diff --git a/src/cascadia/TerminalSettingsEditor/MainPage.cpp b/src/cascadia/TerminalSettingsEditor/MainPage.cpp index d9e7c4a07..71a775cb0 100644 --- a/src/cascadia/TerminalSettingsEditor/MainPage.cpp +++ b/src/cascadia/TerminalSettingsEditor/MainPage.cpp @@ -132,7 +132,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // refresh the current page using the SelectedItem data we collected before the refresh if (selectedItemTag) { - for (const auto& item : menuItemsSTL) + for (const auto& item : menuItems) { if (const auto& menuItem{ item.try_as() }) { @@ -169,14 +169,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - // couldn't find the selected item, - // fallback to first menu item - const auto& firstItem{ menuItems.GetAt(0) }; + // Couldn't find the selected item, fallback to first menu item + // This happens when the selected item was a profile which doesn't exist in the new configuration + // We can use menuItemsSTL here because the only things they miss are profile entries. + const auto& firstItem{ menuItemsSTL.at(0).as() }; SettingsNav().SelectedItem(firstItem); - if (const auto& tag{ SettingsNav().SelectedItem().try_as().Tag() }) - { - _Navigate(unbox_value(tag)); - } + _Navigate(unbox_value(firstItem.Tag())); } void MainPage::SetHostingWindow(uint64_t hostingWindow) noexcept