@@ -267,7 +267,7 @@ public void RegisterResultsUpdatedEvent()
267267
268268 if ( token . IsCancellationRequested ) return ;
269269
270- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , pair . Metadata , e . Query ,
270+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , pair . Metadata , e . Query ,
271271 token ) ) )
272272 {
273273 App . API . LogError ( ClassName , "Unable to add item to Result Update Queue" ) ;
@@ -793,7 +793,7 @@ private ResultsViewModel SelectedResults
793793
794794 public Visibility ProgressBarVisibility { get ; set ; }
795795 public Visibility MainWindowVisibility { get ; set ; }
796-
796+
797797 // This is to be used for determining the visibility status of the main window instead of MainWindowVisibility
798798 // because it is more accurate and reliable representation than using Visibility as a condition check
799799 public bool MainWindowVisibilityStatus { get ; set ; } = true ;
@@ -1070,7 +1070,7 @@ private bool CanExternalPreviewSelectedResult(out string path)
10701070 path = QueryResultsPreviewed ( ) ? Results . SelectedItem ? . Result ? . Preview . FilePath : string . Empty ;
10711071 return ! string . IsNullOrEmpty ( path ) ;
10721072 }
1073-
1073+
10741074 private bool QueryResultsPreviewed ( )
10751075 {
10761076 var previewed = PreviewSelectedItem == Results . SelectedItem ;
@@ -1280,7 +1280,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12801280 // Update the query's IsReQuery property to true if this is a re-query
12811281 query . IsReQuery = isReQuery ;
12821282
1283-
1283+
12841284
12851285 ICollection < PluginPair > plugins = Array . Empty < PluginPair > ( ) ;
12861286 if ( currentIsHomeQuery )
@@ -1312,8 +1312,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13121312 }
13131313 }
13141314
1315- var validPluginNames = plugins . Select ( x => $ "<{ x . Metadata . Name } >") ;
1316- App . API . LogDebug ( ClassName , $ "Valid <{ plugins . Count } > plugins: { string . Join ( " " , validPluginNames ) } ") ;
1315+ App . API . LogDebug ( ClassName , $ "Valid <{ plugins . Count } > plugins: { string . Join ( " " , plugins . Select ( x => $ "<{ x . Metadata . Name } >") ) } ") ;
13171316
13181317 // Do not wait for performance improvement
13191318 /*if (string.IsNullOrEmpty(query.ActionKeyword))
@@ -1341,6 +1340,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13411340 Task [ ] tasks ;
13421341 if ( currentIsHomeQuery )
13431342 {
1343+ if ( ShouldClearExistingResultsForNonQuery ( plugins ) )
1344+ Results . Clear ( ) ;
1345+
13441346 tasks = plugins . Select ( plugin => plugin . Metadata . HomeDisabled switch
13451347 {
13461348 false => QueryTaskAsync ( plugin , currentCancellationToken ) ,
@@ -1432,7 +1434,7 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
14321434 App . API . LogDebug ( ClassName , $ "Update results for plugin <{ plugin . Metadata . Name } >") ;
14331435
14341436 // Indicate if to clear existing results so to show only ones from plugins with action keywords
1435- var shouldClearExistingResults = ShouldClearExistingResults ( query , currentIsHomeQuery ) ;
1437+ var shouldClearExistingResults = ShouldClearExistingResultsForQuery ( query , currentIsHomeQuery ) ;
14361438 _lastQuery = query ;
14371439 _previousIsHomeQuery = currentIsHomeQuery ;
14381440
@@ -1454,8 +1456,13 @@ void QueryHistoryTask(CancellationToken token)
14541456
14551457 App . API . LogDebug ( ClassName , $ "Update results for history") ;
14561458
1459+ // Indicate if to clear existing results so to show only ones from plugins with action keywords
1460+ var shouldClearExistingResults = ShouldClearExistingResultsForQuery ( query , currentIsHomeQuery ) ;
1461+ _lastQuery = query ;
1462+ _previousIsHomeQuery = currentIsHomeQuery ;
1463+
14571464 if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , _historyMetadata , query ,
1458- token ) ) )
1465+ token , reSelect , shouldClearExistingResults ) ) )
14591466 {
14601467 App . API . LogError ( ClassName , "Unable to add item to Result Update Queue" ) ;
14611468 }
@@ -1552,7 +1559,7 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
15521559 /// <param name="query">The current query.</param>
15531560 /// <param name="currentIsHomeQuery">A flag indicating if the current query is a home query.</param>
15541561 /// <returns>True if the existing results should be cleared, false otherwise.</returns>
1555- private bool ShouldClearExistingResults ( Query query , bool currentIsHomeQuery )
1562+ private bool ShouldClearExistingResultsForQuery ( Query query , bool currentIsHomeQuery )
15561563 {
15571564 // If previous or current results are from home query, we need to clear them
15581565 if ( _previousIsHomeQuery || currentIsHomeQuery )
@@ -1571,6 +1578,17 @@ private bool ShouldClearExistingResults(Query query, bool currentIsHomeQuery)
15711578 return false ;
15721579 }
15731580
1581+ private bool ShouldClearExistingResultsForNonQuery ( ICollection < PluginPair > plugins )
1582+ {
1583+ if ( ! Settings . ShowHistoryResultsForHomePage && ( plugins . Count == 0 || plugins . All ( x => x . Metadata . HomeDisabled == true ) ) )
1584+ {
1585+ App . API . LogDebug ( ClassName , $ "Cleared old results") ;
1586+ return true ;
1587+ }
1588+
1589+ return false ;
1590+ }
1591+
15741592 private Result ContextMenuTopMost ( Result result )
15751593 {
15761594 Result menu ;
0 commit comments