@@ -14,6 +14,7 @@ namespace WebSearchShortcut;
1414
1515internal sealed partial class SearchWebPage : DynamicListPage
1616{
17+ private const int MaxHistoryDisplayCount = 3 ;
1718 private const int MaxDisplayCount = 100 ;
1819
1920 private readonly WebSearchShortcutDataEntry _shortcut ;
@@ -97,12 +98,12 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
9798 {
9899 }
99100
101+ var historyItems = BuildHistoryItems ( newSearch ) ;
102+
100103 if ( shouldOpenHomePage )
101104 {
102105 UpdateSuggestionItems ( [ ] , currentEpoch ) ;
103106
104- var historyItems = BuildHistoryItems ( ) ;
105-
106107 RenderItems ( [ _openHomepageListItem , .. historyItems ] , currentEpoch ) ;
107108
108109 return ;
@@ -111,7 +112,7 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
111112 var primaryItems = BuildPrimaryItems ( newSearch ) ;
112113 var snapshotSuggestions = Volatile . Read ( ref _suggestionItems ) ;
113114
114- RenderItems ( [ .. primaryItems , .. snapshotSuggestions ] , currentEpoch ) ;
115+ RenderItems ( [ .. primaryItems , .. historyItems , .. snapshotSuggestions ] , currentEpoch ) ;
115116
116117 if ( ! shouldFetchSuggestions )
117118 return ;
@@ -143,7 +144,7 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
143144
144145 UpdateSuggestionItems ( suggestionItems , currentEpoch ) ;
145146
146- RenderItems ( [ .. primaryItems , .. suggestionItems ] , currentEpoch ) ;
147+ RenderItems ( [ .. primaryItems , .. historyItems , .. suggestionItems ] , currentEpoch ) ;
147148 }
148149
149150 private void RenderItems ( IListItem [ ] items , int currentUpdateSearchTextEpoch )
@@ -196,11 +197,11 @@ private ListItem[] BuildPrimaryItems(string searchText)
196197 ] ;
197198 }
198199
199- private ListItem [ ] BuildHistoryItems ( )
200+ private ListItem [ ] BuildHistoryItems ( string searchText )
200201 {
201202 var historyQueries = HistoryService
202- . Get ( _shortcut . Name )
203- . Take ( MaxDisplayCount - 1 ) ;
203+ . Search ( _shortcut . Name , searchText )
204+ . Take ( string . IsNullOrEmpty ( searchText ) ? MaxDisplayCount : MaxHistoryDisplayCount ) ;
204205
205206 return [
206207 .. historyQueries . Select ( historyQuery => new ListItem (
0 commit comments