Merge branch 'dev' into empty_query

This commit is contained in:
Jack Ye 2025-05-05 08:27:51 +08:00 committed by GitHub
commit 135b9b561a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1244,10 +1244,14 @@ namespace Flow.Launcher.ViewModel
{
_updateSource?.Cancel();
App.API.LogDebug(ClassName, $"Start query with text: <{QueryText}>");
var query = await ConstructQueryAsync(QueryText, Settings.CustomShortcuts, Settings.BuiltinShortcuts);
if (query == null) // shortcut expanded
{
App.API.LogDebug(ClassName, $"Clear query results");
// Hide and clear results again because running query may show and add some results
Results.Visibility = Visibility.Collapsed;
Results.Clear();
@ -1262,6 +1266,8 @@ namespace Flow.Launcher.ViewModel
return;
}
App.API.LogDebug(ClassName, $"Start query with ActionKeyword <{query.ActionKeyword}> and RawQuery <{query.RawQuery}>");
var homeQuery = query.RawQuery == string.Empty;
_updateSource = new CancellationTokenSource();
@ -1313,6 +1319,9 @@ namespace Flow.Launcher.ViewModel
}
}
var validPluginNames = plugins.Select(x => $"<{x.Metadata.Name}>");
App.API.LogDebug(ClassName, $"Valid <{plugins.Count}> plugins: {string.Join(" ", validPluginNames)}");
// Do not wait for performance improvement
/*if (string.IsNullOrEmpty(query.ActionKeyword))
{
@ -1386,6 +1395,8 @@ namespace Flow.Launcher.ViewModel
// Local function
async Task QueryTaskAsync(PluginPair plugin, CancellationToken token)
{
App.API.LogDebug(ClassName, $"Wait for querying plugin <{plugin.Metadata.Name}>");
if (searchDelay && !homeQuery) // Do not delay for home query
{
var searchDelayTime = plugin.Metadata.SearchDelayTime ?? Settings.SearchDelayTime;
@ -1426,6 +1437,8 @@ namespace Flow.Launcher.ViewModel
if (token.IsCancellationRequested) return;
App.API.LogDebug(ClassName, $"Update results for plugin <{plugin.Metadata.Name}>");
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(resultsCopy, plugin.Metadata, query,
token, reSelect)))
{
@ -1442,6 +1455,8 @@ namespace Flow.Launcher.ViewModel
if (_updateSource.Token.IsCancellationRequested) return;
App.API.LogDebug(ClassName, $"Update results for history");
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(results, _historyMetadata, query,
_updateSource.Token)))
{
@ -1537,6 +1552,8 @@ namespace Flow.Launcher.ViewModel
// If last and current query are not home query, we need to check action keyword
else if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
{
App.API.LogDebug(ClassName, $"Remove old results");
Results.Clear();
}
}