diff --git a/Flow.Launcher.Plugin/Query.cs b/Flow.Launcher.Plugin/Query.cs index 84e5dc84e..c3bd82c74 100644 --- a/Flow.Launcher.Plugin/Query.cs +++ b/Flow.Launcher.Plugin/Query.cs @@ -26,6 +26,13 @@ namespace Flow.Launcher.Plugin /// 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 4a95834b5..f864815e4 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 @@ 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 _emptyResult = new List(); - 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);