Improve distinguish between home query and global query

This commit is contained in:
Jack251970 2025-05-04 21:43:48 +08:00
parent 21d6ec20d4
commit 28b8cb6013
3 changed files with 14 additions and 7 deletions

View file

@ -16,8 +16,7 @@ namespace Flow.Launcher.Core.Plugin
Search = string.Empty,
RawQuery = string.Empty,
SearchTerms = Array.Empty<string>(),
// must use null because we need to distinguish between home query and global query
ActionKeyword = null
ActionKeyword = string.Empty
};
}

View file

@ -53,7 +53,6 @@ namespace Flow.Launcher.Plugin
/// <summary>
/// The action keyword part of this query.
/// For global plugins this value will be empty.
/// For home query this value will be null.
/// </summary>
public string ActionKeyword { get; init; }

View file

@ -33,6 +33,7 @@ namespace Flow.Launcher.ViewModel
private bool _isQueryRunning;
private Query _lastQuery;
private bool _lastHomeQuery;
private string _queryTextBeforeLeaveResults;
private string _ignoredQueryText = null;
@ -1261,6 +1262,8 @@ namespace Flow.Launcher.ViewModel
return;
}
var homeQuery = query.RawQuery == string.Empty;
_updateSource = new CancellationTokenSource();
ProgressBarVisibility = Visibility.Hidden;
@ -1275,11 +1278,11 @@ namespace Flow.Launcher.ViewModel
query.IsReQuery = isReQuery;
// handle the exclusiveness of plugin using action keyword
RemoveOldQueryResults(query);
RemoveOldQueryResults(query, homeQuery);
_lastQuery = query;
_lastHomeQuery = homeQuery;
var homeQuery = query.RawQuery == string.Empty;
ICollection<PluginPair> plugins = Array.Empty<PluginPair>();
if (homeQuery)
{
@ -1524,9 +1527,15 @@ namespace Flow.Launcher.ViewModel
}
}
private void RemoveOldQueryResults(Query query)
private void RemoveOldQueryResults(Query query, bool homeQuery)
{
if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
// If last or current query is home query, we need to clear the results
if (_lastHomeQuery || homeQuery)
{
Results.Clear();
}
// If last and current query are not home query, we need to check action keyword
else if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
{
Results.Clear();
}