@@ -274,14 +274,14 @@ public void ReQuery()
274274 {
275275 if ( SelectedIsFromQueryResults ( ) )
276276 {
277- QueryResults ( isReQuery : true ) ;
277+ QueryResults ( null , isReQuery : true ) ;
278278 }
279279 }
280280
281281 public void ReQuery ( bool reselect )
282282 {
283283 BackToQueryResults ( ) ;
284- QueryResults ( isReQuery : true , reSelect : reselect ) ;
284+ QueryResults ( null , isReQuery : true , reSelect : reselect ) ;
285285 }
286286
287287 [ RelayCommand ]
@@ -630,14 +630,14 @@ public void ChangeQueryText(string queryText, bool isReQuery = false)
630630 {
631631 // re-query is done in QueryText's setter method
632632 QueryText = queryText ;
633- Query ( ) ;
633+ Query ( null ) ;
634634 // set to false so the subsequent set true triggers
635635 // PropertyChanged and MoveQueryTextToEnd is called
636636 QueryTextCursorMovedToEnd = false ;
637637 }
638638 else if ( isReQuery )
639639 {
640- Query ( isReQuery : true ) ;
640+ Query ( null , isReQuery : true ) ;
641641 }
642642
643643 QueryTextCursorMovedToEnd = true ;
@@ -690,12 +690,12 @@ private ResultsViewModel SelectedResults
690690 // http://stackoverflow.com/posts/25895769/revisions
691691 if ( string . IsNullOrEmpty ( QueryText ) )
692692 {
693- Query ( ) ;
693+ Query ( null ) ;
694694 }
695695 else
696696 {
697697 QueryText = string . Empty ;
698- Query ( ) ;
698+ Query ( null ) ;
699699 }
700700 }
701701
@@ -979,19 +979,27 @@ private bool CanExternalPreviewSelectedResult(out string path)
979979
980980 #region Query
981981
982- public void Query ( bool isReQuery = false )
982+ public void Query ( int ? searchDelay , bool isReQuery = false )
983983 {
984984 if ( SelectedIsFromQueryResults ( ) )
985985 {
986- QueryResults ( isReQuery ) ;
986+ QueryResults ( searchDelay , isReQuery ) ;
987987 }
988988 else if ( ContextMenuSelected ( ) )
989989 {
990- QueryContextMenu ( ) ;
990+ // Only query history when search delay is null or 0
991+ if ( searchDelay . GetValueOrDefault ( 0 ) == 0 )
992+ {
993+ QueryContextMenu ( ) ;
994+ }
991995 }
992996 else if ( HistorySelected ( ) )
993997 {
994- QueryHistory ( ) ;
998+ // Only query history when search delay is null or 0
999+ if ( searchDelay . GetValueOrDefault ( 0 ) == 0 )
1000+ {
1001+ QueryHistory ( ) ;
1002+ }
9951003 }
9961004 }
9971005
@@ -1081,7 +1089,7 @@ private void QueryHistory()
10811089
10821090 private readonly IReadOnlyList < Result > _emptyResult = new List < Result > ( ) ;
10831091
1084- private async void QueryResults ( bool isReQuery = false , bool reSelect = true )
1092+ private async void QueryResults ( int ? searchDelay , bool isReQuery = false , bool reSelect = true )
10851093 {
10861094 _updateSource ? . Cancel ( ) ;
10871095
@@ -1157,12 +1165,44 @@ private async void QueryResults(bool isReQuery = false, bool reSelect = true)
11571165
11581166 // plugins is ICollection, meaning LINQ will get the Count and preallocate Array
11591167
1160- var tasks = plugins . Select ( plugin => plugin . Metadata . Disabled switch
1168+ Task [ ] tasks ;
1169+ if ( searchDelay . HasValue )
11611170 {
1162- false => QueryTask ( plugin , reSelect ) ,
1163- true => Task . CompletedTask
1164- } ) . ToArray ( ) ;
1171+ var searchDelayValue = searchDelay . Value ;
1172+ tasks = plugins . Select ( plugin => ( plugin . Metadata . Disabled || plugin . Metadata . SearchDelay != searchDelayValue ) switch
1173+ {
1174+ false => QueryTask ( plugin , reSelect ) ,
1175+ true => Task . CompletedTask
1176+ } ) . ToArray ( ) ;
11651177
1178+ // TODO: Remove debug codes.
1179+ System . Diagnostics . Debug . WriteLine ( $ "Querying { searchDelayValue } ms") ;
1180+ foreach ( var plugin in plugins )
1181+ {
1182+ if ( ! ( plugin . Metadata . Disabled || plugin . Metadata . SearchDelay != searchDelayValue ) )
1183+ {
1184+ System . Diagnostics . Debug . WriteLine ( $ "Querying { plugin . Metadata . Name } ") ;
1185+ }
1186+ }
1187+ }
1188+ else
1189+ {
1190+ tasks = plugins . Select ( plugin => plugin . Metadata . Disabled switch
1191+ {
1192+ false => QueryTask ( plugin , reSelect ) ,
1193+ true => Task . CompletedTask
1194+ } ) . ToArray ( ) ;
1195+
1196+ // TODO: Remove debug codes.
1197+ System . Diagnostics . Debug . WriteLine ( $ "Querying null ms") ;
1198+ foreach ( var plugin in plugins )
1199+ {
1200+ if ( ! plugin . Metadata . Disabled )
1201+ {
1202+ System . Diagnostics . Debug . WriteLine ( $ "Querying { plugin . Metadata . Name } ") ;
1203+ }
1204+ }
1205+ }
11661206
11671207 try
11681208 {
0 commit comments