From f3fbbed7ee3d8153fd50c7e673e03415bc9f1545 Mon Sep 17 00:00:00 2001 From: "danisein@qq.com" Date: Sun, 23 Aug 2015 15:40:18 +0800 Subject: [PATCH 1/2] Auto completion for the folder plugin --- Plugins/Wox.Plugin.Folder/FolderPlugin.cs | 44 ++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 622acac0d3..d0fd2f7e91 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -118,11 +118,11 @@ namespace Wox.Plugin.Folder if (driverNames != null && !driverNames.Any(input.StartsWith)) return results; - if (!input.EndsWith("\\")) - { - //"c:" means "the current directory on the C drive" whereas @"c:\" means "root of the C drive" - input = input + "\\"; - } + //if (!input.EndsWith("\\")) + //{ + // //"c:" means "the current directory on the C drive" whereas @"c:\" means "root of the C drive" + // input = input + "\\"; + //} results.AddRange(QueryInternal_Directory_Exists(input)); return results; @@ -142,9 +142,34 @@ namespace Wox.Plugin.Folder private List QueryInternal_Directory_Exists(string rawQuery) { var results = new List(); - if (!Directory.Exists(rawQuery)) return results; + + string incompleteName = ""; + if (!Directory.Exists(rawQuery + "\\")) + { + //if the last component of the path is incomplete, + //then make auto complete for it. + int index = rawQuery.LastIndexOf('\\'); + if (index > 0 && index < (rawQuery.Length - 1)) + { + incompleteName = rawQuery.Substring(index + 1); + incompleteName = incompleteName.ToLower(); + rawQuery = rawQuery.Substring(0, index + 1); + if (!Directory.Exists(rawQuery)) + return results; + } + else + return results; + } + else + { + if (!rawQuery.EndsWith("\\")) + rawQuery += "\\"; + } - results.Add(new Result("Open current directory", "Images/folder.png") + string firstResult = "Open current directory"; + if (incompleteName.Length > 0) + firstResult = "Open " + rawQuery; + results.Add(new Result(firstResult, "Images/folder.png") { Score = 10000, Action = c => @@ -160,6 +185,8 @@ namespace Wox.Plugin.Folder { if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; + if (incompleteName.Length != 0 && !dir.Name.ToLower().StartsWith(incompleteName)) + continue; DirectoryInfo dirCopy = dir; var result = new Result(dir.Name, "Images/folder.png", "Ctrl + Enter to open the directory") { @@ -191,7 +218,8 @@ namespace Wox.Plugin.Folder foreach (FileInfo file in files) { if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; - + if (incompleteName.Length != 0 && !file.Name.ToLower().StartsWith(incompleteName)) + continue; string filePath = file.FullName; var result = new Result(Path.GetFileName(filePath), "Images/file.png") { From ad21909b5ce34b8ebf1d23321447f21f6f81f240 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 4 Nov 2015 16:40:10 +0000 Subject: [PATCH 2/2] Remove unused reference --- Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 0f6c4c5660..84b26a6cd1 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -43,9 +43,6 @@ - - - @@ -145,5 +142,4 @@ --> - - + \ No newline at end of file