From c0d52ef905354c0a58abe9b60838c106aeb680bd Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Thu, 27 Mar 2014 17:25:06 +0800 Subject: [PATCH] Fix duplicated results in CMD --- Wox.Plugin.System/CMD/CMD.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Wox.Plugin.System/CMD/CMD.cs b/Wox.Plugin.System/CMD/CMD.cs index 279e012881..379a2bda2b 100644 --- a/Wox.Plugin.System/CMD/CMD.cs +++ b/Wox.Plugin.System/CMD/CMD.cs @@ -14,6 +14,7 @@ namespace Wox.Plugin.System.CMD protected override List QueryInternal(Query query) { List results = new List(); + List pushedResults = new List(); if (query.RawQuery == ">") { IEnumerable history = CMDStorage.Instance.CMDHistory.OrderByDescending(o => o.Value) @@ -58,6 +59,7 @@ namespace Wox.Plugin.System.CMD catch (Exception) { } context.PushResults(query, new List() { result }); + pushedResults.Add(result); IEnumerable history = CMDStorage.Instance.CMDHistory.Where(o => o.Key.Contains(cmd)) .OrderByDescending(o => o.Value) @@ -93,6 +95,7 @@ namespace Wox.Plugin.System.CMD }).Where(o => o != null).Take(4); context.PushResults(query, history.ToList()); + pushedResults.AddRange(history); try { @@ -113,7 +116,7 @@ namespace Wox.Plugin.System.CMD if (basedir != null) { - List autocomplete = Directory.GetFileSystemEntries(basedir).Select(o => dir + Path.GetFileName(o)).Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); + List autocomplete = Directory.GetFileSystemEntries(basedir).Select(o => dir + Path.GetFileName(o)).Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && !pushedResults.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); autocomplete.Sort(); results.AddRange(autocomplete.ConvertAll(m => new Result() {