@@ -1358,138 +1358,138 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13581358
13591359            try 
13601360            { 
1361-                  // Check if the input text matches the query text 
1362-                  if  ( query . Input  !=  QueryText )  return ; 
1361+             // Check if the input text matches the query text 
1362+             if  ( query . Input  !=  QueryText )  return ; 
13631363
1364-                  App . API . LogDebug ( ClassName ,  $ "Start query with ActionKeyword <{ query . ActionKeyword } > and RawQuery <{ query . RawQuery } >") ; 
1364+             App . API . LogDebug ( ClassName ,  $ "Start query with ActionKeyword <{ query . ActionKeyword } > and RawQuery <{ query . RawQuery } >") ; 
13651365
1366-                  _updateSource ? . Dispose ( ) ; 
1366+             _updateSource ? . Dispose ( ) ; 
13671367
1368-                  var  currentUpdateSource  =  new  CancellationTokenSource ( ) ; 
1369-                  _updateSource  =  currentUpdateSource ; 
1370-                  var  currentCancellationToken  =  _updateSource . Token ; 
1371-                  _updateToken  =  currentCancellationToken ; 
1368+             var  currentUpdateSource  =  new  CancellationTokenSource ( ) ; 
1369+             _updateSource  =  currentUpdateSource ; 
1370+             var  currentCancellationToken  =  _updateSource . Token ; 
1371+             _updateToken  =  currentCancellationToken ; 
13721372
1373-                  ProgressBarVisibility  =  Visibility . Hidden ; 
1373+             ProgressBarVisibility  =  Visibility . Hidden ; 
13741374
1375-                  _progressQuery  =  query ; 
1376-                  _updateQuery  =  query ; 
1375+             _progressQuery  =  query ; 
1376+             _updateQuery  =  query ; 
13771377
1378-                  // Switch to ThreadPool thread 
1379-                  await  TaskScheduler . Default ; 
1378+             // Switch to ThreadPool thread 
1379+             await  TaskScheduler . Default ; 
13801380
1381-                  if  ( currentCancellationToken . IsCancellationRequested )  return ; 
1381+             if  ( currentCancellationToken . IsCancellationRequested )  return ; 
13821382
1383-                  // Update the query's IsReQuery property to true if this is a re-query 
1384-                  query . IsReQuery  =  isReQuery ; 
1383+             // Update the query's IsReQuery property to true if this is a re-query 
1384+             query . IsReQuery  =  isReQuery ; 
13851385
1386-                 ICollection < PluginPair >  plugins  =  Array . Empty < PluginPair > ( ) ; 
1387-                 if  ( currentIsHomeQuery ) 
1386+             ICollection < PluginPair >  plugins  =  Array . Empty < PluginPair > ( ) ; 
1387+             if  ( currentIsHomeQuery ) 
1388+             { 
1389+                 if  ( Settings . ShowHomePage ) 
13881390                { 
1389-                     if  ( Settings . ShowHomePage ) 
1390-                     { 
1391-                         plugins  =  PluginManager . ValidPluginsForHomeQuery ( ) ; 
1392-                     } 
1391+                     plugins  =  PluginManager . ValidPluginsForHomeQuery ( ) ; 
1392+                 } 
13931393
1394-                     PluginIconPath  =  null ; 
1395-                     PluginIconSource  =  null ; 
1396-                     SearchIconVisibility  =  Visibility . Visible ; 
1394+                 PluginIconPath  =  null ; 
1395+                 PluginIconSource  =  null ; 
1396+                 SearchIconVisibility  =  Visibility . Visible ; 
1397+             } 
1398+             else 
1399+             { 
1400+                 plugins  =  PluginManager . ValidPluginsForQuery ( query ,  currentIsDialogJump ) ; 
1401+ 
1402+                 if  ( plugins . Count  ==  1 ) 
1403+                 { 
1404+                     PluginIconPath  =  plugins . Single ( ) . Metadata . IcoPath ; 
1405+                     PluginIconSource  =  await  App . API . LoadImageAsync ( PluginIconPath ) ; 
1406+                     SearchIconVisibility  =  Visibility . Hidden ; 
13971407                } 
13981408                else 
13991409                { 
1400-                     plugins  =  PluginManager . ValidPluginsForQuery ( query ,  currentIsDialogJump ) ; 
1401- 
1402-                     if  ( plugins . Count  ==  1 ) 
1403-                     { 
1404-                         PluginIconPath  =  plugins . Single ( ) . Metadata . IcoPath ; 
1405-                         PluginIconSource  =  await  App . API . LoadImageAsync ( PluginIconPath ) ; 
1406-                         SearchIconVisibility  =  Visibility . Hidden ; 
1407-                     } 
1408-                     else 
1409-                     { 
1410-                         PluginIconPath  =  null ; 
1411-                         PluginIconSource  =  null ; 
1412-                         SearchIconVisibility  =  Visibility . Visible ; 
1413-                     } 
1410+                     PluginIconPath  =  null ; 
1411+                     PluginIconSource  =  null ; 
1412+                     SearchIconVisibility  =  Visibility . Visible ; 
14141413                } 
1414+             } 
14151415
1416-                  App . API . LogDebug ( ClassName ,  $ "Valid <{ plugins . Count } > plugins: { string . Join ( " " ,  plugins . Select ( x =>  $ "<{ x . Metadata . Name } >") ) } ") ; 
1416+             App . API . LogDebug ( ClassName ,  $ "Valid <{ plugins . Count } > plugins: { string . Join ( " " ,  plugins . Select ( x =>  $ "<{ x . Metadata . Name } >") ) } ") ; 
14171417
1418-                  // Do not wait for performance improvement 
1419-                  /*if (string.IsNullOrEmpty(query.ActionKeyword)) 
1420-                  { 
1421-                      // Wait 15 millisecond for query change in global query 
1422-                      // if query changes, return so that it won't be calculated 
1423-                      await Task.Delay(15, currentCancellationToken); 
1424-                      if (currentCancellationToken.IsCancellationRequested) return; 
1425-                  }*/ 
1418+             // Do not wait for performance improvement 
1419+             /*if (string.IsNullOrEmpty(query.ActionKeyword)) 
1420+             { 
1421+                 // Wait 15 millisecond for query change in global query 
1422+                 // if query changes, return so that it won't be calculated 
1423+                 await Task.Delay(15, currentCancellationToken); 
1424+                 if (currentCancellationToken.IsCancellationRequested) return; 
1425+             }*/ 
14261426
1427-                 _  =  Task . Delay ( 200 ,  currentCancellationToken ) . ContinueWith ( _ => 
1427+             _  =  Task . Delay ( 200 ,  currentCancellationToken ) . ContinueWith ( _ => 
1428+             { 
1429+                 // start the progress bar if query takes more than 200 ms and this is the current running query and it didn't finish yet 
1430+                 if  ( _progressQuery  !=  null  &&  _progressQuery . Input  ==  query . Input ) 
14281431                { 
1429-                     // start the progress bar if query takes more than 200 ms and this is the current running query and it didn't finish yet 
1430-                     if  ( _progressQuery  !=  null  &&  _progressQuery . Input  ==  query . Input ) 
1431-                     { 
1432-                         ProgressBarVisibility  =  Visibility . Visible ; 
1433-                     } 
1434-                 } , 
1435-                 currentCancellationToken , 
1436-                 TaskContinuationOptions . NotOnCanceled , 
1437-                 TaskScheduler . Default ) ; 
1432+                     ProgressBarVisibility  =  Visibility . Visible ; 
1433+                 } 
1434+             } , 
1435+             currentCancellationToken , 
1436+             TaskContinuationOptions . NotOnCanceled , 
1437+             TaskScheduler . Default ) ; 
14381438
1439-                  // plugins are ICollection, meaning LINQ will get the Count and preallocate Array 
1439+             // plugins are ICollection, meaning LINQ will get the Count and preallocate Array 
14401440
1441-                 Task [ ]  tasks ; 
1442-                 if  ( currentIsHomeQuery ) 
1441+             Task [ ]  tasks ; 
1442+             if  ( currentIsHomeQuery ) 
1443+             { 
1444+                 if  ( ShouldClearExistingResultsForNonQuery ( plugins ) ) 
14431445                { 
1444-                     if  ( ShouldClearExistingResultsForNonQuery ( plugins ) ) 
1445-                     { 
1446-                         // No update tasks and just return 
1447-                         ClearResults ( ) ; 
1448-                         return ; 
1449-                     } 
1450- 
1451-                     tasks  =  plugins . Select ( plugin =>  plugin . Metadata . HomeDisabled  switch 
1452-                     { 
1453-                         false  =>  QueryTaskAsync ( plugin ,  currentCancellationToken ) , 
1454-                         true  =>  Task . CompletedTask 
1455-                     } ) . ToArray ( ) ; 
1456- 
1457-                     // Query history results for home page firstly so it will be put on top of the results 
1458-                     if  ( Settings . ShowHistoryResultsForHomePage ) 
1459-                     { 
1460-                         QueryHistoryTask ( currentCancellationToken ) ; 
1461-                     } 
1446+                     // No update tasks and just return 
1447+                     ClearResults ( ) ; 
1448+                     return ; 
14621449                } 
1463-                 else 
1450+ 
1451+                 tasks  =  plugins . Select ( plugin =>  plugin . Metadata . HomeDisabled  switch 
14641452                { 
1465-                     tasks  =  plugins . Select ( plugin =>  plugin . Metadata . Disabled  switch 
1466-                     { 
1467-                         false  =>  QueryTaskAsync ( plugin ,  currentCancellationToken ) , 
1468-                         true  =>  Task . CompletedTask 
1469-                     } ) . ToArray ( ) ; 
1470-                 } 
1453+                     false  =>  QueryTaskAsync ( plugin ,  currentCancellationToken ) , 
1454+                     true  =>  Task . CompletedTask 
1455+                 } ) . ToArray ( ) ; 
14711456
1472-                 try 
1457+                 // Query history results for home page firstly so it will be put on top of the results 
1458+                 if  ( Settings . ShowHistoryResultsForHomePage ) 
14731459                { 
1474-                     // Check the code, WhenAll will translate all type of IEnumerable or Collection to Array, so make an array at first 
1475-                     await  Task . WhenAll ( tasks ) ; 
1460+                     QueryHistoryTask ( currentCancellationToken ) ; 
14761461                } 
1477-                 catch  ( OperationCanceledException ) 
1462+             } 
1463+             else 
1464+             { 
1465+                 tasks  =  plugins . Select ( plugin =>  plugin . Metadata . Disabled  switch 
14781466                { 
1479-                     // nothing to do here 
1480-                 } 
1467+                     false  =>  QueryTaskAsync ( plugin ,  currentCancellationToken ) , 
1468+                     true  =>  Task . CompletedTask 
1469+                 } ) . ToArray ( ) ; 
1470+             } 
14811471
1482-                 if  ( currentCancellationToken . IsCancellationRequested )  return ; 
1472+             try 
1473+             { 
1474+                 // Check the code, WhenAll will translate all type of IEnumerable or Collection to Array, so make an array at first 
1475+                 await  Task . WhenAll ( tasks ) ; 
1476+             } 
1477+             catch  ( OperationCanceledException ) 
1478+             { 
1479+                 // nothing to do here 
1480+             } 
14831481
1484-                 // this should happen once after all queries are done so progress bar should continue 
1485-                 // until the end of all querying 
1486-                 _progressQuery  =  null ; 
1482+             if  ( currentCancellationToken . IsCancellationRequested )  return ; 
14871483
1488-                 if  ( ! currentCancellationToken . IsCancellationRequested ) 
1489-                 { 
1490-                     // update to hidden if this is still the current query 
1491-                     ProgressBarVisibility  =  Visibility . Hidden ; 
1492-                 } 
1484+             // this should happen once after all queries are done so progress bar should continue 
1485+             // until the end of all querying 
1486+             _progressQuery  =  null ; 
1487+ 
1488+             if  ( ! currentCancellationToken . IsCancellationRequested ) 
1489+             { 
1490+                 // update to hidden if this is still the current query 
1491+                 ProgressBarVisibility  =  Visibility . Hidden ; 
1492+             } 
14931493            } 
14941494            finally 
14951495            { 
0 commit comments