Merge pull request #3144 from Jack251970/dev4

Add options for setting result on top & keeping result order
This commit is contained in:
Jeremy Wu 2024-12-24 15:10:29 +11:00 committed by GitHub
commit 3d8cf29c8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -263,6 +263,16 @@ namespace Flow.Launcher.Plugin
/// </summary>
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;
/// <summary>
/// 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.
/// </summary>
public bool AddSelectedCount { get; set; } = true;
/// <summary>
/// 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.
/// </summary>
public const int MaxScore = int.MaxValue;
/// <summary>
/// Info of the preview section of a <see cref="Result"/>
/// </summary>

View file

@ -1471,12 +1471,14 @@ namespace Flow.Launcher.ViewModel
{
if (_topMostRecord.IsTopMost(result))
{
result.Score = int.MaxValue;
result.Score = Result.MaxScore;
}
else
else if (result.Score != Result.MaxScore)
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
result.Score += result.AddSelectedCount ?
_userSelectedRecord.GetSelectedCount(result) + priorityScore :
priorityScore;
}
}
}