Skip to content

Commit 2a41f8a

Browse files
committed
improve index
1 parent e56eb74 commit 2a41f8a

File tree

3 files changed

+143
-63
lines changed

3 files changed

+143
-63
lines changed

src/cascadia/TerminalSettingsEditor/MainPage.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
10741074
co_await winrt::resume_foreground(Dispatcher());
10751075
if (searchGeneration != _filteredSearchIndex.generation())
10761076
{
1077+
// TODO CARLOS: look into til::throttled_func (winrt version and non-winrt version) for debounce (used in BellSound and TaskbarProgressUpdates)
10771078
// search index was updated while we were searching, discard results
10781079
co_return;
10791080
}
@@ -1099,18 +1100,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
10991100
}
11001101

11011102
// TODO CARLOS: use the macro below for runtime objects once everything is verified to be working right
1102-
#define APPEND_RUNTIME_OBJECT_RESULTS(runtimeObjectList, runtimeObjectIdentifier, filteredSearchIndex, navigationArgOverride) \
1103-
for (const auto& runtimeObj : runtimeObjectList) \
1104-
{ \
1105-
if (til::contains_linguistic_insensitive(runtimeObjectIdentifier, sanitizedQuery)) \
1106-
{ \
1107-
/*results.push_back(winrt::make<FilteredSearchResult>(, profile));*/ \
1108-
} \
1109-
\
1110-
for (const auto* indexEntry : filteredSearchIndex) \
1111-
{ \
1112-
results.push_back(winrt::make<FilteredSearchResult>(indexEntry, navigationArgOverride)); \
1113-
} \
1103+
#define APPEND_RUNTIME_OBJECT_RESULTS(runtimeObjectList, runtimeObjectIdentifier, filteredSearchIndex, navigationArgOverride) \
1104+
for (const auto& runtimeObj : runtimeObjectList) \
1105+
{ \
1106+
if (til::contains_linguistic_insensitive(runtimeObjectIdentifier, sanitizedQuery)) \
1107+
{ \
1108+
/*results.push_back(winrt::make<FilteredSearchResult>(<NEED ANOTHER PARAM>, runtimeObj, runtimeObjectIdentifier));*/ \
1109+
} \
1110+
\
1111+
for (const auto* indexEntry : filteredSearchIndex) \
1112+
{ \
1113+
results.push_back(winrt::make<FilteredSearchResult>(indexEntry, navigationArgOverride)); \
1114+
} \
11141115
}
11151116

11161117
// Profiles
@@ -1122,7 +1123,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
11221123
{
11231124
// TODO CARLOS: if name matches, link the top-level page
11241125
// can't do that rn because I need a LocalizedIndexEntry stored somewhere for that
1125-
//results.push_back(winrt::make<FilteredSearchResult>(, profile));
1126+
// SPECIFICALLY, I NEED TO CONVERT PartialProfileIndexEntry into a LocalizedIndexEntry (which is dumb, because there's nothing to localize)
1127+
//results.push_back(winrt::make<FilteredSearchResult>(&PartialProfileIndexEntry(), profile));//, std::optional<hstring>{ profile.Name() }));
11261128
}
11271129

11281130
for (const auto* indexEntry : _filteredSearchProfileIndex)

src/cascadia/TerminalSettingsEditor/MainPage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
4242
FilteredSearchResult(const winrt::hstring& label) :
4343
_overrideLabel{ label } {}
4444

45-
FilteredSearchResult(const LocalizedIndexEntry* entry, const Windows::Foundation::IInspectable& navigationArgOverride = nullptr) :
45+
FilteredSearchResult(const LocalizedIndexEntry* entry, const Windows::Foundation::IInspectable& navigationArgOverride = nullptr, const std::optional<hstring>& label = std::nullopt) :
4646
_SearchIndexEntry{ entry },
47-
_NavigationArgOverride{ navigationArgOverride } {}
47+
_NavigationArgOverride{ navigationArgOverride },
48+
_overrideLabel{ label } {}
4849

4950
hstring ToString() { return Label(); }
5051

tools/GenerateSettingsIndex.ps1

Lines changed: 125 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -93,58 +93,126 @@ Get-ChildItem -Path $SourceDir -Recurse -Filter *.xaml | ForEach-Object {
9393
$subPage += 'None'
9494
}
9595

96-
if ($filename -eq 'ColorSchemes.xaml')
96+
# Register top-level pages
97+
if ($filename -eq 'Launch.xaml')
9798
{
98-
# ColorSchemes.xaml doesn't have any SettingContainers!
99-
100-
# TODO CARLOS: remove from script; hard code in MainPage instead
101-
# Register the page itself
102-
# $entries += [pscustomobject]@{
103-
# DisplayText = 'vm'
104-
# ParentPage = "winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::ColorSchemes>()"
105-
# NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
106-
# SubPage = 'BreadcrumbSubPage::ColorSchemes_Edit'
107-
# ElementName = 'L""'
108-
# File = $filename
109-
# }
110-
111-
# TODO CARLOS: remove from script; hard code in MainPage instead
99+
$entries += [pscustomobject]@{
100+
DisplayTextLocalized = "RS_(L`"Nav_Launch/Content`")"
101+
HelpTextLocalized = "std::nullopt"
102+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
103+
NavigationParam = "winrt::box_value(hstring{L`"Launch_Nav`"})"
104+
SubPage = "BreadcrumbSubPage::None"
105+
ElementName = 'L""'
106+
File = $filename
107+
}
108+
}
109+
elseif ($filename -eq 'Interaction.xaml')
110+
{
111+
$entries += [pscustomobject]@{
112+
DisplayTextLocalized = "RS_(L`"Nav_Interaction/Content`")"
113+
HelpTextLocalized = "std::nullopt"
114+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
115+
NavigationParam = "winrt::box_value(hstring{L`"Interaction_Nav`"})"
116+
SubPage = "BreadcrumbSubPage::None"
117+
ElementName = 'L""'
118+
File = $filename
119+
}
120+
}
121+
elseif ($filename -eq 'GlobalAppearance.xaml')
122+
{
123+
$entries += [pscustomobject]@{
124+
DisplayTextLocalized = "RS_(L`"Nav_Appearance/Content`")"
125+
HelpTextLocalized = "std::nullopt"
126+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
127+
NavigationParam = "winrt::box_value(hstring{L`"Appearance_Nav`"})"
128+
SubPage = "BreadcrumbSubPage::None"
129+
ElementName = 'L""'
130+
File = $filename
131+
}
132+
}
133+
elseif ($filename -eq 'ColorSchemes.xaml')
134+
{
135+
$entries += [pscustomobject]@{
136+
DisplayTextLocalized = "RS_(L`"Nav_ColorSchemes/Content`")"
137+
HelpTextLocalized = "std::nullopt"
138+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
139+
NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
140+
SubPage = "BreadcrumbSubPage::None"
141+
ElementName = 'L""'
142+
File = $filename
143+
}
144+
112145
# Manually register the "add new" button
113-
# $entries += [pscustomobject]@{
114-
# DisplayText = 'RS_(L"ColorScheme_AddNewButton/Text")'
115-
# ParentPage = "winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::ColorSchemes>()"
116-
# NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
117-
# SubPage = 'BreadcrumbSubPage::None'
118-
# ElementName = 'L"AddNewButton"'
119-
# File = $filename
120-
# }
121-
return
146+
$entries += [pscustomobject]@{
147+
DisplayTextLocalized = 'RS_(L"ColorScheme_AddNewButton/Text")'
148+
HelpTextLocalized = 'std::nullopt'
149+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
150+
NavigationParam = "winrt::box_value(hstring{L`"ColorSchemes_Nav`"})"
151+
SubPage = 'BreadcrumbSubPage::None'
152+
ElementName = 'L"AddNewButton"'
153+
File = $filename
154+
}
155+
156+
}
157+
elseif ($filename -eq 'Rendering.xaml')
158+
{
159+
$entries += [pscustomobject]@{
160+
DisplayTextLocalized = "RS_(L`"Nav_Rendering/Content`")"
161+
HelpTextLocalized = "std::nullopt"
162+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
163+
NavigationParam = "winrt::box_value(hstring{L`"Rendering_Nav`"})"
164+
SubPage = "BreadcrumbSubPage::None"
165+
ElementName = 'L""'
166+
File = $filename
167+
}
168+
}
169+
elseif ($filename -eq 'Compatibility.xaml')
170+
{
171+
$entries += [pscustomobject]@{
172+
DisplayTextLocalized = "RS_(L`"Nav_Compatibility/Content`")"
173+
HelpTextLocalized = "std::nullopt"
174+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
175+
NavigationParam = "winrt::box_value(hstring{L`"Compatibility_Nav`"})"
176+
SubPage = "BreadcrumbSubPage::None"
177+
ElementName = 'L""'
178+
File = $filename
179+
}
180+
}
181+
elseif ($filename -eq 'Actions.xaml')
182+
{
183+
$entries += [pscustomobject]@{
184+
DisplayTextLocalized = "RS_(L`"Nav_Actions/Content`")"
185+
HelpTextLocalized = "std::nullopt"
186+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
187+
NavigationParam = "winrt::box_value(hstring{L`"Actions_Nav`"})"
188+
SubPage = "BreadcrumbSubPage::None"
189+
ElementName = 'L""'
190+
File = $filename
191+
}
192+
}
193+
elseif ($filename -eq 'NewTabMenu.xaml')
194+
{
195+
$entries += [pscustomobject]@{
196+
DisplayTextLocalized = "RS_(L`"Nav_NewTabMenu/Content`")"
197+
HelpTextLocalized = "std::nullopt"
198+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
199+
NavigationParam = "winrt::box_value(hstring{L`"NewTabMenu_Nav`"})"
200+
SubPage = "BreadcrumbSubPage::None"
201+
ElementName = 'L""'
202+
File = $filename
203+
}
122204
}
123205
elseif ($filename -eq 'Extensions.xaml')
124206
{
125-
126-
# TODO CARLOS: remove from script; hard code in MainPage instead
127-
# Register the main extension page
128-
# $entries += [pscustomobject]@{
129-
# DisplayText = 'RS_(L"Nav_Extensions/Content")'
130-
# ParentPage = "winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::Extensions>()"
131-
# NavigationParam = "nullptr"
132-
# SubPage = 'BreadcrumbSubPage::None'
133-
# ElementName = 'L""'
134-
# File = $filename
135-
# }
136-
137-
# TODO CARLOS: remove from script; hard code in MainPage instead
138-
# Register the extension view
139-
# $entries += [pscustomobject]@{
140-
# DisplayText = 'vm.Package().DisplayName()'
141-
# ParentPage = "winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::Extensions>()"
142-
# NavigationParam = "vm"
143-
# SubPage = 'BreadcrumbSubPage::Extensions_Extension'
144-
# ElementName = 'L""'
145-
# File = $filename
146-
# }
147-
return
207+
$entries += [pscustomobject]@{
208+
DisplayTextLocalized = "RS_(L`"Nav_Extensions/Content`")"
209+
HelpTextLocalized = "std::nullopt"
210+
ParentPage = "winrt::xaml_typename<$($pageClass)>()"
211+
NavigationParam = "winrt::box_value(hstring{L`"Extensions_Nav`"})"
212+
SubPage = "BreadcrumbSubPage::None"
213+
ElementName = 'L""'
214+
File = $filename
215+
}
148216
}
149217

150218
# Find all local:SettingContainer start tags
@@ -286,7 +354,7 @@ Get-ChildItem -Path $SourceDir -Recurse -Filter *.xaml | ForEach-Object {
286354
}
287355

288356
# Ensure there aren't any duplicate entries
289-
$entries = $entries | Sort-Object RootUid, ParentPage, NavigationParam, SubPage, ElementName, File -Unique
357+
$entries = $entries | Sort-Object DisplayTextLocalized, HelpTextLocalized, ParentPage, NavigationParam, SubPage, ElementName, File -Unique
290358

291359
$buildTimeEntries = @()
292360
$profileEntries = @()
@@ -340,6 +408,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
340408
// May not exist for all entries
341409
std::optional<hstring> HelpTextLocalized;
342410
411+
// TODO CARLOS: this might not be necessary; remove
343412
// x:Class of the parent Page (i.e. winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::Launch>())
344413
winrt::Windows::UI::Xaml::Interop::TypeName ParentPage;
345414
@@ -357,6 +426,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
357426
const std::array<IndexEntry, $($profileEntries.Count)>& LoadProfileIndex();
358427
const std::array<IndexEntry, $($ntmEntries.Count)>& LoadNTMFolderIndex();
359428
const std::array<IndexEntry, $($schemeEntries.Count)>& LoadColorSchemeIndex();
429+
430+
const IndexEntry& PartialProfileIndexEntry();
360431
}
361432
"@
362433

@@ -406,6 +477,12 @@ $( ($schemeEntries -join "`r`n") )
406477
};
407478
return entries;
408479
}
480+
481+
const IndexEntry& PartialProfileIndexEntry()
482+
{
483+
static IndexEntry entry{ L"", std::nullopt, winrt::xaml_typename<Microsoft::Terminal::Settings::Editor::Profiles_Base>(), nullptr, BreadcrumbSubPage::None, L"" };
484+
return entry;
485+
}
409486
}
410487
"@
411488

0 commit comments

Comments
 (0)