@@ -307,6 +307,7 @@ public void ReQuery()
307307 {
308308 if ( QueryResultsSelected ( ) )
309309 {
310+ App . API . LogDebug ( ClassName , $ "Search Delay: { false } , Is Requery: { true } , Reselect: { true } ") ;
310311 // When we are re-querying, we should not delay the query
311312 _ = QueryResultsAsync ( false , isReQuery : true ) ;
312313 }
@@ -315,6 +316,7 @@ public void ReQuery()
315316 public void ReQuery ( bool reselect )
316317 {
317318 BackToQueryResults ( ) ;
319+ App . API . LogDebug ( ClassName , $ "Search Delay: { false } , Is Requery: { true } , Reselect: { reselect } ") ;
318320 // When we are re-querying, we should not delay the query
319321 _ = QueryResultsAsync ( false , isReQuery : true , reSelect : reselect ) ;
320322 }
@@ -1077,6 +1079,7 @@ public void Query(bool searchDelay, bool isReQuery = false)
10771079 {
10781080 if ( QueryResultsSelected ( ) )
10791081 {
1082+ App . API . LogDebug ( ClassName , $ "Search Delay: { searchDelay } , Is Requery: { isReQuery } , Reselect: { true } ") ;
10801083 _ = QueryResultsAsync ( searchDelay , isReQuery ) ;
10811084 }
10821085 else if ( ContextMenuSelected ( ) )
@@ -1093,6 +1096,7 @@ private async Task QueryAsync(bool searchDelay, bool isReQuery = false)
10931096 {
10941097 if ( QueryResultsSelected ( ) )
10951098 {
1099+ App . API . LogDebug ( ClassName , $ "Search Delay: { searchDelay } , Is Requery: { isReQuery } , Reselect: { true } ") ;
10961100 await QueryResultsAsync ( searchDelay , isReQuery ) ;
10971101 }
10981102 else if ( ContextMenuSelected ( ) )
@@ -1196,22 +1200,26 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
11961200 {
11971201 _updateSource ? . Cancel ( ) ;
11981202
1203+ App . API . LogDebug ( ClassName , $ "Query construct for QueryText: { QueryText } ") ;
1204+
11991205 var query = ConstructQuery ( QueryText , Settings . CustomShortcuts , Settings . BuiltinShortcuts ) ;
12001206
12011207 if ( query == null ) // shortcut expanded
12021208 {
1209+ App . API . LogDebug ( ClassName , $ "Query null for QueryText: null") ;
1210+
12031211 // Wait last query to be canceled and then do resetting actions
12041212 await _updateLock . WaitAsync ( CancellationToken . None ) ;
12051213 try
12061214 {
12071215 // Reset results
1208- Results . Clear ( ) ;
1209- Results . Visibility = Visibility . Collapsed ;
1216+ Results . Clear ( ) ;
1217+ Results . Visibility = Visibility . Collapsed ;
12101218
12111219 // Reset plugin icon
1212- PluginIconPath = null ;
1213- PluginIconSource = null ;
1214- SearchIconVisibility = Visibility . Visible ;
1220+ PluginIconPath = null ;
1221+ PluginIconSource = null ;
1222+ SearchIconVisibility = Visibility . Visible ;
12151223
12161224 // Reset progress bar
12171225 ProgressBarVisibility = Visibility . Hidden ;
@@ -1226,6 +1234,8 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12261234 // Switch to ThreadPool thread to keep UI responsive when waiting update lock
12271235 await TaskScheduler . Default ;
12281236
1237+ App . API . LogDebug ( ClassName , $ "Wait for QueryText: { query . RawQuery } ") ;
1238+
12291239 await _updateLock . WaitAsync ( CancellationToken . None ) ;
12301240 try
12311241 {
@@ -1235,24 +1245,34 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12351245
12361246 ProgressBarVisibility = Visibility . Hidden ;
12371247
1248+ App . API . LogDebug ( ClassName , $ "Start for QueryText: { query . RawQuery } ") ;
1249+ App . API . LogDebug ( ClassName , $ "ProgressBar: { Visibility . Hidden } ") ;
1250+
12381251 _runningQuery = query ;
12391252
12401253 // Switch to ThreadPool thread
12411254 await TaskScheduler . Default ;
12421255
12431256 if ( _updateSource . Token . IsCancellationRequested )
1257+ {
1258+ App . API . LogDebug ( ClassName , $ "Cancel for QueryText: { query . RawQuery } ") ;
12441259 return ;
1260+ }
12451261
12461262 // Update the query's IsReQuery property to true if this is a re-query
12471263 query . IsReQuery = isReQuery ;
12481264
12491265 // handle the exclusiveness of plugin using action keyword
12501266 RemoveOldQueryResults ( query ) ;
12511267
1268+ App . API . LogDebug ( ClassName , $ "Remove old for QueryText: { query . RawQuery } ") ;
1269+
12521270 _lastQuery = query ;
12531271
12541272 var plugins = PluginManager . ValidPluginsForQuery ( query ) ;
12551273
1274+ App . API . LogDebug ( ClassName , $ "Valid { plugins . Count } plugins QueryText: { query . RawQuery } ") ;
1275+
12561276 if ( plugins . Count == 1 )
12571277 {
12581278 PluginIconPath = plugins . Single ( ) . Metadata . IcoPath ;
@@ -1278,10 +1298,14 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12781298
12791299 _ = Task . Delay ( 200 , _updateSource . Token ) . ContinueWith ( _ =>
12801300 {
1301+ App . API . LogDebug ( ClassName , $ "Check ProgressBar for QueryText: running: { _runningQuery ? . RawQuery ?? "null" } query: { query . RawQuery } ") ;
1302+
12811303 // start the progress bar if query takes more than 200 ms and this is the current running query and it didn't finish yet
12821304 if ( _runningQuery != null && _runningQuery == query )
12831305 {
12841306 ProgressBarVisibility = Visibility . Visible ;
1307+
1308+ App . API . LogDebug ( ClassName , $ "ProgressBar: { Visibility . Visible } ") ;
12851309 }
12861310 } ,
12871311 _updateSource . Token ,
@@ -1307,7 +1331,10 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13071331 }
13081332
13091333 if ( _updateSource . Token . IsCancellationRequested )
1334+ {
1335+ App . API . LogDebug ( ClassName , $ "Cancel for QueryText: { QueryText } ") ;
13101336 return ;
1337+ }
13111338
13121339 // this should happen once after all queries are done so progress bar should continue
13131340 // until the end of all querying
@@ -1317,10 +1344,13 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13171344 {
13181345 // update to hidden if this is still the current query
13191346 ProgressBarVisibility = Visibility . Hidden ;
1347+
1348+ App . API . LogDebug ( ClassName , $ "ProgressBar: { Visibility . Hidden } ") ;
13201349 }
13211350 }
13221351 finally
13231352 {
1353+ App . API . LogDebug ( ClassName , $ "Query return for QueryText: { QueryText } ") ;
13241354 _updateLock . Release ( ) ;
13251355 }
13261356
@@ -1334,7 +1364,10 @@ async Task QueryTaskAsync(PluginPair plugin)
13341364 await Task . Delay ( searchDelayTime , _updateSource . Token ) ;
13351365
13361366 if ( _updateSource . Token . IsCancellationRequested )
1367+ {
1368+ App . API . LogDebug ( ClassName , $ "Cancel for QueryText: { QueryText } ") ;
13371369 return ;
1370+ }
13381371 }
13391372
13401373 // Since it is wrapped within a ThreadPool Thread, the synchronous context is null
@@ -1344,7 +1377,10 @@ async Task QueryTaskAsync(PluginPair plugin)
13441377 var results = await PluginManager . QueryForPluginAsync ( plugin , query , _updateSource . Token ) ;
13451378
13461379 if ( _updateSource . Token . IsCancellationRequested )
1380+ {
1381+ App . API . LogDebug ( ClassName , $ "Cancel for QueryText: { query . RawQuery } ") ;
13471382 return ;
1383+ }
13481384
13491385 IReadOnlyList < Result > resultsCopy ;
13501386 if ( results == null )
@@ -1366,13 +1402,20 @@ async Task QueryTaskAsync(PluginPair plugin)
13661402 }
13671403
13681404 if ( _updateSource . Token . IsCancellationRequested )
1405+ {
1406+ App . API . LogDebug ( ClassName , $ "Cancel for QueryText: { query . RawQuery } ") ;
13691407 return ;
1408+ }
13701409
13711410 if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( resultsCopy , plugin . Metadata , query ,
13721411 _updateSource . Token , reSelect ) ) )
13731412 {
13741413 App . API . LogError ( ClassName , "Unable to add item to Result Update Queue" ) ;
13751414 }
1415+ else
1416+ {
1417+ App . API . LogDebug ( ClassName , $ "Write updates for QueryText: { query . RawQuery } ") ;
1418+ }
13761419 }
13771420 }
13781421
0 commit comments