diff --git a/src/cascadia/TerminalSettingsEditor/SearchIndex.cpp b/src/cascadia/TerminalSettingsEditor/SearchIndex.cpp index e8fdb533cf..443e58361c 100644 --- a/src/cascadia/TerminalSettingsEditor/SearchIndex.cpp +++ b/src/cascadia/TerminalSettingsEditor/SearchIndex.cpp @@ -66,8 +66,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation hstring runtimeObjContext{}; if (const auto profileVM = runtimeObj.try_as()) { - // No runtimeObjContext: profile name and icon should be enough runtimeObjLabel = profileVM.Name(); + runtimeObjContext = RS_(L"Nav_Profiles/Content"); } else if (const auto colorSchemeVM = runtimeObj.try_as()) { @@ -258,6 +258,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { localizedEntry.DisplayTextNeutral = EnglishOnlyResourceLoader().GetLocalizedString(entry.ResourceName); } + if (!entry.SecondaryLabelResourceName.empty()) + { + localizedEntry.SecondaryLabelLocalized = GetLibraryResourceString(entry.SecondaryLabelResourceName); + } localizedIndex.emplace_back(std::move(localizedEntry)); } return localizedIndex; @@ -342,7 +346,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation if (bestScore >= MinimumMatchScore) { - scoredResults.emplace_back(bestScore, winrt::make(index, &entry)); + scoredResults.emplace_back(bestScore, winrt::make(index, &entry, nullptr, std::nullopt, entry.SecondaryLabelLocalized)); } } diff --git a/src/cascadia/TerminalSettingsEditor/SearchIndex.h b/src/cascadia/TerminalSettingsEditor/SearchIndex.h index 276102d7dc..46536b601d 100644 --- a/src/cascadia/TerminalSettingsEditor/SearchIndex.h +++ b/src/cascadia/TerminalSettingsEditor/SearchIndex.h @@ -20,6 +20,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { winrt::hstring DisplayTextLocalized; std::optional DisplayTextNeutral = std::nullopt; + // No "Neutral" copy of SecondaryLabelLocalized: unlike DisplayText, the secondary + // label is display-only (rendered in the search result row's caption). It is never + // passed to the fuzzy matcher, so a single localized string is sufficient. + winrt::hstring SecondaryLabelLocalized; const IndexEntry* Entry = nullptr; std::array, int>, 2> GetSearchableFields() const; diff --git a/tools/GenerateSettingsIndex.ps1 b/tools/GenerateSettingsIndex.ps1 index 5b1db56a69..2122ab2d44 100644 --- a/tools/GenerateSettingsIndex.ps1 +++ b/tools/GenerateSettingsIndex.ps1 @@ -85,6 +85,7 @@ $ClassMap = @{ ResourceName = "Nav_ProfileDefaults/Content" NavigationParam = "GlobalProfile_Nav" SubPage = "BreadcrumbSubPage::None" + SecondaryLabel = "Nav_Profiles/Content" } "Microsoft::Terminal::Settings::Editor::Profiles_Appearance" = @{ ResourceName = "Nav_ProfileDefaults/Content" @@ -105,6 +106,7 @@ $ClassMap = @{ ResourceName = "Nav_AddNewProfile/Content" NavigationParam = "AddProfile" SubPage = "BreadcrumbSubPage::None" + SecondaryLabel = "Nav_Profiles/Content" } "Microsoft::Terminal::Settings::Editor::Profiles" = @{ ResourceName = "Nav_Profiles/Content" @@ -161,6 +163,7 @@ foreach ($xamlFile in Get-ChildItem -Path $SourceDir -Filter *.xaml) NavigationParam = $ClassMap[$pageClass].NavigationParam SubPage = $ClassMap[$pageClass].SubPage ElementName = $null # No specific element to navigate to, for the page itself + SecondaryLabel = $ClassMap[$pageClass].SecondaryLabel # Resource name for the result's sub-text (i.e. parent page name); $null if none File = $filename } } @@ -194,6 +197,7 @@ foreach ($xamlFile in Get-ChildItem -Path $SourceDir -Filter *.xaml) NavigationParam = $ClassMap[$pageClass].NavigationParam SubPage = $ClassMap[$pageClass].SubPage ElementName = "AddNewButton" + SecondaryLabel = $ClassMap[$pageClass].SecondaryLabel File = $filename } } @@ -290,8 +294,9 @@ function FormatEntry($e) $formattedResourceName = 'USES_RESOURCE(L"{0}")' -f $e.ResourceName $formattedNavigationParam = 'L"{0}"' -f $e.NavigationParam # null Navigation param resolves to empty string $formattedElementName = 'L"{0}"' -f $e.ElementName + $formattedSecondaryLabel = [string]::IsNullOrEmpty($e.SecondaryLabel) ? 'L""' : ('USES_RESOURCE(L"{0}")' -f $e.SecondaryLabel) - return " IndexEntry{{ {0}, {1}, {2}, {3} }}, // {4}" -f ($formattedResourceName, $formattedNavigationParam, $e.SubPage, $formattedElementName, $e.File) + return " IndexEntry{{ {0}, {1}, {2}, {3}, {4} }}, // {5}" -f ($formattedResourceName, $formattedNavigationParam, $e.SubPage, $formattedElementName, $formattedSecondaryLabel, $e.File) } function FormatEntries($es) { @@ -299,7 +304,7 @@ function FormatEntries($es) { } # Sort and remove duplicates -$entries = $entries | Sort-Object ResourceName, ParentPage, NavigationParam, SubPage, ElementName, File -Unique +$entries = $entries | Sort-Object ResourceName, ParentPage, NavigationParam, SubPage, ElementName, SecondaryLabel, File -Unique $buildTimeEntries = @() $profileEntries = @() @@ -355,6 +360,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // x:Name of the SettingContainer to navigate to on the page (i.e. "DefaultProfile") wil::zwstring_view ElementName; + + // Resource name of the search result's secondary label (i.e. parent page name like "Nav_Profiles/Content"). + // Empty if the entry has no secondary label. + // NOTE: wrapped in USES_RESOURCE() like ResourceName when non-empty. + wil::zwstring_view SecondaryLabelResourceName; }; const std::array& LoadBuildTimeIndex();