diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index 0a9921f73..47ebb4a95 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -190,13 +190,16 @@ namespace Flow.Launcher.Storage // remove the record from the bag var bag = new ConcurrentQueue(value.Where(r => !r.Equals(result))); - records[result.OriginQuery.RawQuery] = new ConcurrentBag(bag); - - // if the bag is empty, remove the bag from the dictionary - if (value.IsEmpty) + if (bag.IsEmpty) { + // if the bag is empty, remove the bag from the dictionary records.TryRemove(result.OriginQuery.RawQuery, out _); } + else + { + // change the bag in the dictionary + records[result.OriginQuery.RawQuery] = new ConcurrentBag(bag); + } } internal void AddOrUpdate(Result result)