mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2174 from JohnTheGr8/requery_enhancements
Improvements for re-queries
This commit is contained in:
commit
0047d8accc
3 changed files with 29 additions and 7 deletions
|
|
@ -26,6 +26,13 @@ namespace Flow.Launcher.Plugin
|
|||
/// </summary>
|
||||
public string RawQuery { get; internal init; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the query was forced to execute again.
|
||||
/// For example, the value will be true when the user presses Ctrl + R.
|
||||
/// When this property is true, plugins handling this query should avoid serving cached results.
|
||||
/// </summary>
|
||||
public bool IsReQuery { get; internal set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Search part of a query.
|
||||
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@
|
|||
Key="O"
|
||||
Command="{Binding LoadContextMenuCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="R"
|
||||
Command="{Binding ReQueryCommand}"
|
||||
Modifiers="Ctrl" />
|
||||
<KeyBinding
|
||||
Key="H"
|
||||
Command="{Binding LoadHistoryCommand}"
|
||||
|
|
|
|||
|
|
@ -205,6 +205,15 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ReQuery()
|
||||
{
|
||||
if (SelectedIsFromQueryResults())
|
||||
{
|
||||
QueryResults(isReQuery: true);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void LoadContextMenu()
|
||||
{
|
||||
|
|
@ -495,8 +504,8 @@ namespace Flow.Launcher.ViewModel
|
|||
/// but we don't want to move cursor to end when query is updated from TextBox
|
||||
/// </summary>
|
||||
/// <param name="queryText"></param>
|
||||
/// <param name="reQuery">Force query even when Query Text doesn't change</param>
|
||||
public void ChangeQueryText(string queryText, bool reQuery = false)
|
||||
/// <param name="isReQuery">Force query even when Query Text doesn't change</param>
|
||||
public void ChangeQueryText(string queryText, bool isReQuery = false)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
|
@ -510,9 +519,9 @@ namespace Flow.Launcher.ViewModel
|
|||
QueryTextCursorMovedToEnd = false;
|
||||
|
||||
}
|
||||
else if (reQuery)
|
||||
else if (isReQuery)
|
||||
{
|
||||
Query();
|
||||
Query(isReQuery: true);
|
||||
}
|
||||
QueryTextCursorMovedToEnd = true;
|
||||
});
|
||||
|
|
@ -612,11 +621,11 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
#region Query
|
||||
|
||||
public void Query()
|
||||
public void Query(bool isReQuery = false)
|
||||
{
|
||||
if (SelectedIsFromQueryResults())
|
||||
{
|
||||
QueryResults();
|
||||
QueryResults(isReQuery);
|
||||
}
|
||||
else if (ContextMenuSelected())
|
||||
{
|
||||
|
|
@ -716,7 +725,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
private readonly IReadOnlyList<Result> _emptyResult = new List<Result>();
|
||||
|
||||
private async void QueryResults()
|
||||
private async void QueryResults(bool isReQuery = false)
|
||||
{
|
||||
_updateSource?.Cancel();
|
||||
|
||||
|
|
@ -747,6 +756,8 @@ namespace Flow.Launcher.ViewModel
|
|||
if (currentCancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
// Update the query's IsReQuery property to true if this is a re-query
|
||||
query.IsReQuery = isReQuery;
|
||||
|
||||
// handle the exclusiveness of plugin using action keyword
|
||||
RemoveOldQueryResults(query);
|
||||
|
|
|
|||
Loading…
Reference in a new issue