Skip to content

Commit 92febf0

Browse files
authored
Merge pull request #117 from jjw24/folderplugin_updatesearch_sorting
Folder plugin updates to searching and sorting of results
2 parents 1c711ae + ac6ee28 commit 92febf0

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Plugins/Wox.Plugin.Folder/Main.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,14 @@ private List<Result> QueryInternal_Directory_Exists(Query query)
191191
if (incompleteName.StartsWith(">"))
192192
{
193193
searchOption = SearchOption.AllDirectories;
194-
incompleteName = incompleteName.Substring(1);
194+
195+
// match everything before and after search term using supported wildcard '*', ie. *searchterm*
196+
incompleteName = "*" + incompleteName.Substring(1);
195197
}
196-
198+
199+
var folderList = new List<Result>();
200+
var fileList = new List<Result>();
201+
197202
try
198203
{
199204
// search folder and add results
@@ -204,11 +209,14 @@ private List<Result> QueryInternal_Directory_Exists(Query query)
204209
{
205210
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
206211

207-
var result =
208-
fileSystemInfo is DirectoryInfo
209-
? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query)
210-
: CreateFileResult(fileSystemInfo.FullName, query);
211-
results.Add(result);
212+
if(fileSystemInfo is DirectoryInfo)
213+
{
214+
folderList.Add(CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query));
215+
}
216+
else
217+
{
218+
fileList.Add(CreateFileResult(fileSystemInfo.FullName, query));
219+
}
212220
}
213221
}
214222
catch (Exception e)
@@ -223,7 +231,8 @@ fileSystemInfo is DirectoryInfo
223231
throw;
224232
}
225233

226-
return results;
234+
// Intial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
235+
return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList();
227236
}
228237

229238
private static Result CreateFileResult(string filePath, Query query)

0 commit comments

Comments
 (0)