diff --git a/Flow.Launcher.Plugin/Query.cs b/Flow.Launcher.Plugin/Query.cs index 95547d27350..3ee44f6b6a9 100644 --- a/Flow.Launcher.Plugin/Query.cs +++ b/Flow.Launcher.Plugin/Query.cs @@ -29,6 +29,13 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm /// public string RawQuery { get; internal init; } + /// + /// 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. + /// + public bool IsReQuery { get; internal set; } = false; + /// /// Search part of a query. /// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery. diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 4a95834b534..f864815e4f3 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -86,6 +86,10 @@ Key="O" Command="{Binding LoadContextMenuCommand}" Modifiers="Ctrl" /> + /// - /// Force query even when Query Text doesn't change - public void ChangeQueryText(string queryText, bool reQuery = false) + /// Force query even when Query Text doesn't change + public void ChangeQueryText(string queryText, bool isReQuery = false) { Application.Current.Dispatcher.Invoke(() => { @@ -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; }); @@ -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()) { @@ -716,7 +725,7 @@ private void QueryHistory() private readonly IReadOnlyList _emptyResult = new List(); - private async void QueryResults() + private async void QueryResults(bool isReQuery = false) { _updateSource?.Cancel(); @@ -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);