Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Flow.Launcher.Plugin/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm
/// </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.
Expand Down
4 changes: 4 additions & 0 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
25 changes: 18 additions & 7 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ private void LoadHistory()
}
}

[RelayCommand]
private void ReQuery()
{
if (SelectedIsFromQueryResults())
{
QueryResults(isReQuery: true);
}
}

[RelayCommand]
private void LoadContextMenu()
{
Expand Down Expand Up @@ -495,8 +504,8 @@ private void UpdatePreview()
/// 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(() =>
{
Expand All @@ -510,9 +519,9 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
QueryTextCursorMovedToEnd = false;

}
else if (reQuery)
else if (isReQuery)
{
Query();
Query(isReQuery: true);
}
QueryTextCursorMovedToEnd = true;
});
Expand Down Expand Up @@ -612,11 +621,11 @@ public string PreviewHotkey

#region Query

public void Query()
public void Query(bool isReQuery = false)
{
if (SelectedIsFromQueryResults())
{
QueryResults();
QueryResults(isReQuery);
}
else if (ContextMenuSelected())
{
Expand Down Expand Up @@ -716,7 +725,7 @@ private void QueryHistory()

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

private async void QueryResults()
private async void QueryResults(bool isReQuery = false)
{
_updateSource?.Cancel();

Expand Down Expand Up @@ -747,6 +756,8 @@ private async void QueryResults()
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);
Expand Down