diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
index e618b5c36..1b5f315f6 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs
@@ -59,6 +59,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
{
EverythingApiDllImport.Everything_GetMajorVersion();
var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError;
+
return result;
}
finally
@@ -67,6 +68,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
}
}
+ const int ScoreScaleFactor = 5;
+
///
/// Searches the specified key word and reset the everything API afterwards
///
@@ -115,7 +118,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
EverythingApiDllImport.Everything_SetSort(option.SortOption);
EverythingApiDllImport.Everything_SetMatchPath(option.IsFullPathSearch);
-
+
if (option.SortOption == SortOption.RUN_COUNT_DESCENDING)
{
EverythingApiDllImport.Everything_SetRequestFlags(EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME | EVERYTHING_REQUEST_RUN_COUNT);
@@ -132,10 +135,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
if (!EverythingApiDllImport.Everything_QueryW(true))
{
CheckAndThrowExceptionOnError();
+
yield break;
}
- for (var idx = 0; idx < EverythingApiDllImport.Everything_GetNumResults(); ++idx)
+ var numResults = EverythingApiDllImport.Everything_GetNumResults();
+
+ for (var idx = 0; idx < numResults; ++idx)
{
if (token.IsCancellationRequested)
{
@@ -151,7 +157,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
Type = EverythingApiDllImport.Everything_IsFolderResult(idx) ? ResultType.Folder :
EverythingApiDllImport.Everything_IsFileResult(idx) ? ResultType.File :
ResultType.Volume,
- Score = (int)EverythingApiDllImport.Everything_GetResultRunCount( (uint)idx)
+ Score = (option.SortOption is SortOption.RUN_COUNT_DESCENDING ? (int)EverythingApiDllImport.Everything_GetResultRunCount((uint)idx) : 0) * ScoreScaleFactor,
+ WindowsIndexed = false
};
yield return result;
@@ -192,6 +199,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
public static async Task IncrementRunCounterAsync(string fileOrFolder)
{
await _semaphore.WaitAsync(TimeSpan.FromSeconds(1));
+
try
{
_ = EverythingApiDllImport.Everything_IncRunCountFromFileName(fileOrFolder);
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
index 51c4c3d9d..375fd6ce5 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
@@ -29,12 +29,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public class PathEqualityComparator : IEqualityComparer
{
private static PathEqualityComparator instance;
+
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();
public bool Equals(Result x, Result y)
{
return x.Title.Equals(y.Title, StringComparison.OrdinalIgnoreCase)
- && string.Equals(x.SubTitle, y.SubTitle, StringComparison.OrdinalIgnoreCase);
+ && string.Equals(x.SubTitle, y.SubTitle, StringComparison.OrdinalIgnoreCase);
}
public int GetHashCode(Result obj)
@@ -106,7 +107,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
try
{
- await foreach (var search in searchResults.WithCancellation(token).ConfigureAwait(false))
+ await foreach (var search in searchResults.Select((r, i) => r with
+ {
+ Score = -i + 50
+ }).WithCancellation(token).ConfigureAwait(false))
results.Add(ResultManager.CreateResult(query, search));
}
catch (OperationCanceledException)