@@ -214,18 +214,7 @@ async Task UpdateActionAsync()
214214 await Task . Delay ( 20 ) ;
215215 while ( channelReader . TryRead ( out var item ) )
216216 {
217- if ( item . shouldClearExistingResults )
218- {
219- cancelIndex ++ ;
220- if ( cancelIndex > 1 )
221- {
222- // Assume one task for clearing existing results is cancelled
223- continue ;
224- }
225- }
226-
227-
228- if ( ! item . Token . IsCancellationRequested )
217+ if ( item . shouldClearExistingResults || ! item . Token . IsCancellationRequested )
229218 queue [ item . ID ] = item ;
230219 }
231220
@@ -1450,6 +1439,16 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
14501439 _lastQuery = query ;
14511440 _previousIsHomeQuery = currentIsHomeQuery ;
14521441
1442+ // Test: Assume first query task for clearing existing results is cancelled
1443+ if ( shouldClearExistingResults )
1444+ {
1445+ cancelIndex ++ ;
1446+ if ( cancelIndex == 2 )
1447+ {
1448+ currentUpdateSource . Cancel ( ) ;
1449+ }
1450+ }
1451+
14531452 if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , plugin . Metadata , query ,
14541453 token , reSelect , shouldClearExistingResults ) ) )
14551454 {
@@ -1874,7 +1873,9 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
18741873 {
18751874 if ( ! resultsForUpdates . Any ( ) )
18761875 return ;
1876+
18771877 CancellationToken token ;
1878+ var shouldClearExistingResults = resultsForUpdates . Any ( r => r . shouldClearExistingResults ) ;
18781879
18791880 try
18801881 {
@@ -1936,7 +1937,7 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
19361937 // it should be the same for all results
19371938 bool reSelect = resultsForUpdates . First ( ) . ReSelectFirstResult ;
19381939
1939- Results . AddResults ( resultsForUpdates , token , reSelect ) ;
1940+ Results . AddResults ( resultsForUpdates , token , reSelect , shouldClearExistingResults ) ;
19401941 }
19411942
19421943 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Performance" , "CA1822:Mark members as static" , Justification = "<Pending>" ) ]
0 commit comments