@@ -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 ;
@@ -98,12 +99,12 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
9899 {
99100 }
100101
102+ var historyItems = BuildHistoryItems ( newSearch ) ;
103+
101104 if ( shouldOpenHomePage )
102105 {
103106 UpdateSuggestionItems ( [ ] , currentEpoch ) ;
104107
105- var historyItems = BuildHistoryItems ( ) ;
106-
107108 RenderItems ( [ _openHomepageListItem , .. historyItems ] , currentEpoch ) ;
108109
109110 return ;
@@ -112,7 +113,7 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
112113 var primaryItems = BuildPrimaryItems ( newSearch ) ;
113114 var snapshotSuggestions = Volatile . Read ( ref _suggestionItems ) ;
114115
115- RenderItems ( [ .. primaryItems , .. snapshotSuggestions ] , currentEpoch ) ;
116+ RenderItems ( [ .. primaryItems , .. historyItems , .. snapshotSuggestions ] , currentEpoch ) ;
116117
117118 if ( ! shouldFetchSuggestions )
118119 return ;
@@ -144,7 +145,7 @@ public override async void UpdateSearchText(string oldSearch, string newSearch)
144145
145146 UpdateSuggestionItems ( suggestionItems , currentEpoch ) ;
146147
147- RenderItems ( [ .. primaryItems , .. suggestionItems ] , currentEpoch ) ;
148+ RenderItems ( [ .. primaryItems , .. historyItems , .. suggestionItems ] , currentEpoch ) ;
148149 }
149150
150151 private void RenderItems ( IListItem [ ] items , int currentUpdateSearchTextEpoch )
@@ -197,11 +198,11 @@ private ListItem[] BuildPrimaryItems(string searchText)
197198 ] ;
198199 }
199200
200- private ListItem [ ] BuildHistoryItems ( )
201+ private ListItem [ ] BuildHistoryItems ( string searchText )
201202 {
202203 var historyQueries = HistoryService
203- . Get ( _shortcut . Name )
204- . Take ( MaxDisplayCount - 1 ) ;
204+ . Search ( _shortcut . Name , searchText )
205+ . Take ( string . IsNullOrEmpty ( searchText ) ? MaxDisplayCount : MaxHistoryDisplayCount ) ;
205206
206207 return [
207208 .. historyQueries . Select ( historyQuery => new ListItem (
0 commit comments