diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b0bd49657..2fd00224c 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -135,13 +135,17 @@ namespace Flow.Launcher.ViewModel var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) => { - if (e.Query.RawQuery == QueryText && !e.Token.IsCancellationRequested) + if (e.Query.RawQuery != QueryText || e.Token.IsCancellationRequested) { - PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); - if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, e.Token))) - { - Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); - } + return; + } + + var token = e.Token == default ? _updateToken : e.Token; + + PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); + if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, token))) + { + Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); } }; } @@ -459,7 +463,7 @@ namespace Flow.Launcher.ViewModel } private readonly IReadOnlyList _emptyResult = new List(); - + private async void QueryResults() { _updateSource?.Cancel(); @@ -553,7 +557,7 @@ namespace Flow.Launcher.ViewModel await Task.Yield(); IReadOnlyList results = await PluginManager.QueryForPluginAsync(plugin, query, currentCancellationToken); - + currentCancellationToken.ThrowIfCancellationRequested(); results ??= _emptyResult;