From fd7120028439e50b92ca4bd7e185fe82e77b5cb9 Mon Sep 17 00:00:00 2001 From: cxfksword Date: Mon, 24 Mar 2014 21:14:56 +0800 Subject: [PATCH] Directory change use fuzzy to search --- Wox.Plugin.System/DirectoryIndicator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Wox.Plugin.System/DirectoryIndicator.cs b/Wox.Plugin.System/DirectoryIndicator.cs index 3f76b69be3..c89d020050 100644 --- a/Wox.Plugin.System/DirectoryIndicator.cs +++ b/Wox.Plugin.System/DirectoryIndicator.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; +using Wox.Infrastructure; namespace Wox.Plugin.System { @@ -104,14 +105,17 @@ namespace Wox.Plugin.System parentDir = parentDir.TrimEnd('\\', '/'); if (parentDirectories.ContainsKey(parentDir)) { + var dirs = parentDirectories[parentDir]; var queryFileName = Path.GetFileName(query.RawQuery).ToLower(); + var fuzzy = FuzzyMatcher.Create(queryFileName); foreach (var dir in dirs) { if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; - if (!dir.Name.ToLower().StartsWith(queryFileName)) + var matchResult = fuzzy.Evaluate(dir.Name); + if (!matchResult.Success) continue; var dirPath = dir.FullName; @@ -119,6 +123,7 @@ namespace Wox.Plugin.System { Title = dir.Name, IcoPath = "Images/folder.png", + Score = matchResult.Score, Action = (c) => { context.ChangeQuery(dirPath);