Merge pull request #117 from jjw24/folderplugin_updatesearch_sorting

Folder plugin updates to searching and sorting of results
This commit is contained in:
theClueless 2020-01-13 00:51:27 +02:00 committed by GitHub
commit 92febf0b00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,9 +191,14 @@ namespace Wox.Plugin.Folder
if (incompleteName.StartsWith(">"))
{
searchOption = SearchOption.AllDirectories;
incompleteName = incompleteName.Substring(1);
// match everything before and after search term using supported wildcard '*', ie. *searchterm*
incompleteName = "*" + incompleteName.Substring(1);
}
var folderList = new List<Result>();
var fileList = new List<Result>();
try
{
// search folder and add results
@ -204,11 +209,14 @@ namespace Wox.Plugin.Folder
{
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
var result =
fileSystemInfo is DirectoryInfo
? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query)
: CreateFileResult(fileSystemInfo.FullName, query);
results.Add(result);
if(fileSystemInfo is DirectoryInfo)
{
folderList.Add(CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query));
}
else
{
fileList.Add(CreateFileResult(fileSystemInfo.FullName, query));
}
}
}
catch (Exception e)
@ -223,7 +231,8 @@ namespace Wox.Plugin.Folder
throw;
}
return results;
// Intial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList();
}
private static Result CreateFileResult(string filePath, Query query)