From 3057cdcf2c3d26e6c095e78f9de8568d7a7b989b Mon Sep 17 00:00:00 2001 From: Corey Hayward Date: Sun, 16 Feb 2025 17:11:11 +0000 Subject: [PATCH 1/3] Allow preventing selected result data retrieval --- src/modules/launcher/Wox.Plugin/Result.cs | 6 ++++++ src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Wox.Plugin/Result.cs b/src/modules/launcher/Wox.Plugin/Result.cs index 91f026bbb200..c2d8ab799e06 100644 --- a/src/modules/launcher/Wox.Plugin/Result.cs +++ b/src/modules/launcher/Wox.Plugin/Result.cs @@ -187,5 +187,11 @@ public override string ToString() /// Gets plugin ID that generated this result /// public string PluginID { get; internal set; } + + /// + /// Gets or sets a value indicating whether the selected data should be applied to this result. + /// + /// Enabling this option will affect the sort ordering of this result + public bool DisableSelectedDataRetrieval { get; set; } } } diff --git a/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs b/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs index 4989c7a51a22..b7d7bfe68774 100644 --- a/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs +++ b/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs @@ -106,7 +106,7 @@ public UserSelectedRecordItem GetSelectedData(Result result) { ArgumentNullException.ThrowIfNull(result); - if (result != null && Records.TryGetValue(result.ToString(), out var value)) + if (result != null && !result.DisableSelectedDataRetrieval && Records.TryGetValue(result.ToString(), out var value)) { return value; } From 2ce895a0832c84deecf1826cdeb83aa384bbda3a Mon Sep 17 00:00:00 2001 From: Corey Hayward Date: Mon, 17 Feb 2025 08:56:49 +0000 Subject: [PATCH 2/3] Updated implementation to calculate sort order on result and update property name to better reflect purpose --- .../PowerLauncher/ViewModel/ResultsViewModel.cs | 4 ++-- src/modules/launcher/Wox.Plugin/Result.cs | 15 ++++++++++++--- .../launcher/Wox.Plugin/UserSelectedRecord.cs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs index 02e6138b3094..c418b32e9209 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultsViewModel.cs @@ -282,11 +282,11 @@ public void Sort(MainViewModel.QueryTuningOptions options) if (options.SearchQueryTuningEnabled) { - sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * options.SearchClickedItemWeight))).ToList(); + sorted = Results.OrderByDescending(x => x.Result.GetSortOrder(options.SearchClickedItemWeight)).ToList(); } else { - sorted = Results.OrderByDescending(x => (x.Result.Metadata.WeightBoost + x.Result.Score + (x.Result.SelectedCount * 5))).ToList(); + sorted = Results.OrderByDescending(x => x.Result.GetSortOrder(5)).ToList(); } // remove history items in they are in the list as non-history items diff --git a/src/modules/launcher/Wox.Plugin/Result.cs b/src/modules/launcher/Wox.Plugin/Result.cs index c2d8ab799e06..8290403d27b0 100644 --- a/src/modules/launcher/Wox.Plugin/Result.cs +++ b/src/modules/launcher/Wox.Plugin/Result.cs @@ -189,9 +189,18 @@ public override string ToString() public string PluginID { get; internal set; } /// - /// Gets or sets a value indicating whether the selected data should be applied to this result. + /// Gets or sets a value indicating whether usage based sorting should be applied to this result. /// - /// Enabling this option will affect the sort ordering of this result - public bool DisableSelectedDataRetrieval { get; set; } + public bool DisableUsageBasedScoring { get; set; } + + public int GetSortOrder(int selectedItemMultiplier) + { + if (DisableUsageBasedScoring) + { + return Metadata.WeightBoost + Score; + } + + return Metadata.WeightBoost + Score + (SelectedCount * selectedItemMultiplier); + } } } diff --git a/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs b/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs index b7d7bfe68774..4989c7a51a22 100644 --- a/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs +++ b/src/modules/launcher/Wox.Plugin/UserSelectedRecord.cs @@ -106,7 +106,7 @@ public UserSelectedRecordItem GetSelectedData(Result result) { ArgumentNullException.ThrowIfNull(result); - if (result != null && !result.DisableSelectedDataRetrieval && Records.TryGetValue(result.ToString(), out var value)) + if (result != null && Records.TryGetValue(result.ToString(), out var value)) { return value; } From b85b5298dd98cbbde828fb5805bc315b37f470a2 Mon Sep 17 00:00:00 2001 From: coreyH <72159232+CoreyHayward@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:58:31 +0000 Subject: [PATCH 3/3] Update Result.cs sort order method name Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com> --- src/modules/launcher/Wox.Plugin/Result.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/launcher/Wox.Plugin/Result.cs b/src/modules/launcher/Wox.Plugin/Result.cs index 8290403d27b0..3bbb6dbf5e10 100644 --- a/src/modules/launcher/Wox.Plugin/Result.cs +++ b/src/modules/launcher/Wox.Plugin/Result.cs @@ -193,7 +193,7 @@ public override string ToString() /// public bool DisableUsageBasedScoring { get; set; } - public int GetSortOrder(int selectedItemMultiplier) + public int GetSortOrderScore(int selectedItemMultiplier) { if (DisableUsageBasedScoring) {