@@ -267,7 +267,7 @@ public void RegisterResultsUpdatedEvent()
267
267
268
268
if ( token . IsCancellationRequested ) return ;
269
269
270
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , pair . Metadata , e . Query ,
270
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , pair . Metadata , e . Query ,
271
271
token ) ) )
272
272
{
273
273
App . API . LogError ( ClassName , "Unable to add item to Result Update Queue" ) ;
@@ -793,7 +793,7 @@ private ResultsViewModel SelectedResults
793
793
794
794
public Visibility ProgressBarVisibility { get ; set ; }
795
795
public Visibility MainWindowVisibility { get ; set ; }
796
-
796
+
797
797
// This is to be used for determining the visibility status of the main window instead of MainWindowVisibility
798
798
// because it is more accurate and reliable representation than using Visibility as a condition check
799
799
public bool MainWindowVisibilityStatus { get ; set ; } = true ;
@@ -1070,7 +1070,7 @@ private bool CanExternalPreviewSelectedResult(out string path)
1070
1070
path = QueryResultsPreviewed ( ) ? Results . SelectedItem ? . Result ? . Preview . FilePath : string . Empty ;
1071
1071
return ! string . IsNullOrEmpty ( path ) ;
1072
1072
}
1073
-
1073
+
1074
1074
private bool QueryResultsPreviewed ( )
1075
1075
{
1076
1076
var previewed = PreviewSelectedItem == Results . SelectedItem ;
@@ -1280,7 +1280,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
1280
1280
// Update the query's IsReQuery property to true if this is a re-query
1281
1281
query . IsReQuery = isReQuery ;
1282
1282
1283
-
1283
+
1284
1284
1285
1285
ICollection < PluginPair > plugins = Array . Empty < PluginPair > ( ) ;
1286
1286
if ( currentIsHomeQuery )
@@ -1312,8 +1312,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
1312
1312
}
1313
1313
}
1314
1314
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 } >") ) } ") ;
1317
1316
1318
1317
// Do not wait for performance improvement
1319
1318
/*if (string.IsNullOrEmpty(query.ActionKeyword))
@@ -1341,6 +1340,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
1341
1340
Task [ ] tasks ;
1342
1341
if ( currentIsHomeQuery )
1343
1342
{
1343
+ if ( ShouldClearExistingResultsForNonQuery ( plugins ) )
1344
+ Results . Clear ( ) ;
1345
+
1344
1346
tasks = plugins . Select ( plugin => plugin . Metadata . HomeDisabled switch
1345
1347
{
1346
1348
false => QueryTaskAsync ( plugin , currentCancellationToken ) ,
@@ -1432,7 +1434,7 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
1432
1434
App . API . LogDebug ( ClassName , $ "Update results for plugin <{ plugin . Metadata . Name } >") ;
1433
1435
1434
1436
// 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 ) ;
1436
1438
_lastQuery = query ;
1437
1439
_previousIsHomeQuery = currentIsHomeQuery ;
1438
1440
@@ -1454,8 +1456,13 @@ void QueryHistoryTask(CancellationToken token)
1454
1456
1455
1457
App . API . LogDebug ( ClassName , $ "Update results for history") ;
1456
1458
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
+
1457
1464
if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , _historyMetadata , query ,
1458
- token ) ) )
1465
+ token , reSelect , shouldClearExistingResults ) ) )
1459
1466
{
1460
1467
App . API . LogError ( ClassName , "Unable to add item to Result Update Queue" ) ;
1461
1468
}
@@ -1552,7 +1559,7 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
1552
1559
/// <param name="query">The current query.</param>
1553
1560
/// <param name="currentIsHomeQuery">A flag indicating if the current query is a home query.</param>
1554
1561
/// <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 )
1556
1563
{
1557
1564
// If previous or current results are from home query, we need to clear them
1558
1565
if ( _previousIsHomeQuery || currentIsHomeQuery )
@@ -1571,6 +1578,17 @@ private bool ShouldClearExistingResults(Query query, bool currentIsHomeQuery)
1571
1578
return false ;
1572
1579
}
1573
1580
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
+
1574
1592
private Result ContextMenuTopMost ( Result result )
1575
1593
{
1576
1594
Result menu ;
0 commit comments