Skip to content

Commit 0047d8a

Browse files
authored
Merge pull request #2174 from JohnTheGr8/requery_enhancements
Improvements for re-queries
2 parents 1b68d09 + f22ce37 commit 0047d8a

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

Flow.Launcher.Plugin/Query.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm
2626
/// </summary>
2727
public string RawQuery { get; internal init; }
2828

29+
/// <summary>
30+
/// Determines whether the query was forced to execute again.
31+
/// For example, the value will be true when the user presses Ctrl + R.
32+
/// When this property is true, plugins handling this query should avoid serving cached results.
33+
/// </summary>
34+
public bool IsReQuery { get; internal set; } = false;
35+
2936
/// <summary>
3037
/// Search part of a query.
3138
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.

Flow.Launcher/MainWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
Key="O"
8787
Command="{Binding LoadContextMenuCommand}"
8888
Modifiers="Ctrl" />
89+
<KeyBinding
90+
Key="R"
91+
Command="{Binding ReQueryCommand}"
92+
Modifiers="Ctrl" />
8993
<KeyBinding
9094
Key="H"
9195
Command="{Binding LoadHistoryCommand}"

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ private void LoadHistory()
205205
}
206206
}
207207

208+
[RelayCommand]
209+
private void ReQuery()
210+
{
211+
if (SelectedIsFromQueryResults())
212+
{
213+
QueryResults(isReQuery: true);
214+
}
215+
}
216+
208217
[RelayCommand]
209218
private void LoadContextMenu()
210219
{
@@ -495,8 +504,8 @@ private void UpdatePreview()
495504
/// but we don't want to move cursor to end when query is updated from TextBox
496505
/// </summary>
497506
/// <param name="queryText"></param>
498-
/// <param name="reQuery">Force query even when Query Text doesn't change</param>
499-
public void ChangeQueryText(string queryText, bool reQuery = false)
507+
/// <param name="isReQuery">Force query even when Query Text doesn't change</param>
508+
public void ChangeQueryText(string queryText, bool isReQuery = false)
500509
{
501510
Application.Current.Dispatcher.Invoke(() =>
502511
{
@@ -510,9 +519,9 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
510519
QueryTextCursorMovedToEnd = false;
511520

512521
}
513-
else if (reQuery)
522+
else if (isReQuery)
514523
{
515-
Query();
524+
Query(isReQuery: true);
516525
}
517526
QueryTextCursorMovedToEnd = true;
518527
});
@@ -612,11 +621,11 @@ public string PreviewHotkey
612621

613622
#region Query
614623

615-
public void Query()
624+
public void Query(bool isReQuery = false)
616625
{
617626
if (SelectedIsFromQueryResults())
618627
{
619-
QueryResults();
628+
QueryResults(isReQuery);
620629
}
621630
else if (ContextMenuSelected())
622631
{
@@ -716,7 +725,7 @@ private void QueryHistory()
716725

717726
private readonly IReadOnlyList<Result> _emptyResult = new List<Result>();
718727

719-
private async void QueryResults()
728+
private async void QueryResults(bool isReQuery = false)
720729
{
721730
_updateSource?.Cancel();
722731

@@ -747,6 +756,8 @@ private async void QueryResults()
747756
if (currentCancellationToken.IsCancellationRequested)
748757
return;
749758

759+
// Update the query's IsReQuery property to true if this is a re-query
760+
query.IsReQuery = isReQuery;
750761

751762
// handle the exclusiveness of plugin using action keyword
752763
RemoveOldQueryResults(query);

0 commit comments

Comments
 (0)