From f05767afe861afb681e87a2b9cabce87f35070b9 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 9 Dec 2019 08:27:50 +1100 Subject: [PATCH 1/3] Add exceptions for unauth and arg not found when searching --- Plugins/Wox.Plugin.Folder/Main.cs | 36 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Plugins/Wox.Plugin.Folder/Main.cs b/Plugins/Wox.Plugin.Folder/Main.cs index 0e81623785..487974ceb4 100644 --- a/Plugins/Wox.Plugin.Folder/Main.cs +++ b/Plugins/Wox.Plugin.Folder/Main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -157,18 +157,32 @@ namespace Wox.Plugin.Folder incompleteName = incompleteName.Substring(1); } - // search folder and add results - var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption); - - foreach (var fileSystemInfo in fileSystemInfos) + try { - if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; + // search folder and add results + var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption); - var result = - fileSystemInfo is DirectoryInfo - ? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query.ActionKeyword) - : CreateFileResult(fileSystemInfo.FullName); - results.Add(result); + foreach (var fileSystemInfo in fileSystemInfos) + { + if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue; + + var result = + fileSystemInfo is DirectoryInfo + ? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query.ActionKeyword) + : CreateFileResult(fileSystemInfo.FullName); + results.Add(result); + } + } + catch(Exception e) + { + if (e is UnauthorizedAccessException || e is ArgumentException) + { + results.Add(new Result { Title = e.Message, Score = 501 }); + + return results; + } + + throw; } return results; From 4f38a953ac39fd5951f079d1904957aa0470451e Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 9 Dec 2019 08:28:22 +1100 Subject: [PATCH 2/3] Add handling when query action keyword is empty --- Plugins/Wox.Plugin.Folder/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Wox.Plugin.Folder/Main.cs b/Plugins/Wox.Plugin.Folder/Main.cs index 487974ceb4..de01072845 100644 --- a/Plugins/Wox.Plugin.Folder/Main.cs +++ b/Plugins/Wox.Plugin.Folder/Main.cs @@ -82,7 +82,7 @@ namespace Wox.Plugin.Folder } string changeTo = path.EndsWith("\\") ? path : path + "\\"; - _context.API.ChangeQuery(queryActionKeyword + " " + changeTo); + _context.API.ChangeQuery(string.IsNullOrEmpty(queryActionKeyword)? changeTo : queryActionKeyword + " " + changeTo); return false; } }; From 0acb4f5aed3d0d0bc6e5bb868c97dad86c191dff Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 9 Dec 2019 08:29:20 +1100 Subject: [PATCH 3/3] lower the score for folder results A search of other scores shows highest is 500, except for calculated score from String.Matcher --- Plugins/Wox.Plugin.Folder/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Wox.Plugin.Folder/Main.cs b/Plugins/Wox.Plugin.Folder/Main.cs index de01072845..73725d35f7 100644 --- a/Plugins/Wox.Plugin.Folder/Main.cs +++ b/Plugins/Wox.Plugin.Folder/Main.cs @@ -220,7 +220,7 @@ namespace Wox.Plugin.Folder { Title = firstResult, IcoPath = search, - Score = 10000, + Score = 500, Action = c => { Process.Start(search);