From 1ed1c9993166d1dc72fbc17fea6ee17444838c08 Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Wed, 15 Mar 2023 20:53:14 +0200 Subject: [PATCH] Revert "add scoring based on index and small optimization" This reverts commit 02b321c4a36f4946777345bbc75eb4f16fee5597. --- .../Search/Everything/EverythingAPI.cs | 14 +++----------- .../Search/SearchManager.cs | 8 ++------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index 1b5f315f6..e618b5c36 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -59,7 +59,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything { EverythingApiDllImport.Everything_GetMajorVersion(); var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError; - return result; } finally @@ -68,8 +67,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything } } - const int ScoreScaleFactor = 5; - /// /// Searches the specified key word and reset the everything API afterwards /// @@ -118,7 +115,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); @@ -135,13 +132,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything if (!EverythingApiDllImport.Everything_QueryW(true)) { CheckAndThrowExceptionOnError(); - yield break; } - var numResults = EverythingApiDllImport.Everything_GetNumResults(); - - for (var idx = 0; idx < numResults; ++idx) + for (var idx = 0; idx < EverythingApiDllImport.Everything_GetNumResults(); ++idx) { if (token.IsCancellationRequested) { @@ -157,8 +151,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything Type = EverythingApiDllImport.Everything_IsFolderResult(idx) ? ResultType.Folder : EverythingApiDllImport.Everything_IsFileResult(idx) ? ResultType.File : ResultType.Volume, - Score = (option.SortOption is SortOption.RUN_COUNT_DESCENDING ? (int)EverythingApiDllImport.Everything_GetResultRunCount((uint)idx) : 0) * ScoreScaleFactor, - WindowsIndexed = false + Score = (int)EverythingApiDllImport.Everything_GetResultRunCount( (uint)idx) }; yield return result; @@ -199,7 +192,6 @@ 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 375fd6ce5..51c4c3d9d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -29,13 +29,12 @@ 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) @@ -107,10 +106,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search try { - await foreach (var search in searchResults.Select((r, i) => r with - { - Score = -i + 50 - }).WithCancellation(token).ConfigureAwait(false)) + await foreach (var search in searchResults.WithCancellation(token).ConfigureAwait(false)) results.Add(ResultManager.CreateResult(query, search)); } catch (OperationCanceledException)