Skip to content

Commit 3d8cf29

Browse files
authored
Merge pull request #3144 from Jack251970/dev4
Add options for setting result on top & keeping result order
2 parents eef2f3d + 269e583 commit 3d8cf29

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
263263
/// </summary>
264264
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;
265265

266+
/// <summary>
267+
/// Determines if the user selection count should be added to the score. This can be useful when set to false to allow the result sequence order to be the same everytime instead of changing based on selection.
268+
/// </summary>
269+
public bool AddSelectedCount { get; set; } = true;
270+
271+
/// <summary>
272+
/// Maximum score. This can be useful when set one result to the top by default. This is the score for the results set to the topmost by users.
273+
/// </summary>
274+
public const int MaxScore = int.MaxValue;
275+
266276
/// <summary>
267277
/// Info of the preview section of a <see cref="Result"/>
268278
/// </summary>

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,12 +1471,14 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
14711471
{
14721472
if (_topMostRecord.IsTopMost(result))
14731473
{
1474-
result.Score = int.MaxValue;
1474+
result.Score = Result.MaxScore;
14751475
}
1476-
else
1476+
else if (result.Score != Result.MaxScore)
14771477
{
14781478
var priorityScore = metaResults.Metadata.Priority * 150;
1479-
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
1479+
result.Score += result.AddSelectedCount ?
1480+
_userSelectedRecord.GetSelectedCount(result) + priorityScore :
1481+
priorityScore;
14801482
}
14811483
}
14821484
}

0 commit comments

Comments
 (0)