mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Add sorting
order by result title asc, then type being folder first.
This commit is contained in:
@@ -195,7 +195,10 @@ namespace Wox.Plugin.Folder
|
|||||||
// match everything before and after search term using supported wildcard '*', ie. *searchterm*
|
// match everything before and after search term using supported wildcard '*', ie. *searchterm*
|
||||||
incompleteName = "*" + incompleteName.Substring(1);
|
incompleteName = "*" + incompleteName.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var folderList = new List<Result>();
|
||||||
|
var fileList = new List<Result>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// search folder and add results
|
// search folder and add results
|
||||||
@@ -206,11 +209,14 @@ namespace Wox.Plugin.Folder
|
|||||||
{
|
{
|
||||||
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
||||||
|
|
||||||
var result =
|
if(fileSystemInfo is DirectoryInfo)
|
||||||
fileSystemInfo is DirectoryInfo
|
{
|
||||||
? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query)
|
folderList.Add(CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query));
|
||||||
: CreateFileResult(fileSystemInfo.FullName, query);
|
}
|
||||||
results.Add(result);
|
else
|
||||||
|
{
|
||||||
|
fileList.Add(CreateFileResult(fileSystemInfo.FullName, query));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -225,7 +231,8 @@ namespace Wox.Plugin.Folder
|
|||||||
throw;
|
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)
|
private static Result CreateFileResult(string filePath, Query query)
|
||||||
|
|||||||
Reference in New Issue
Block a user