mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use deep clone for result updating
This commit is contained in:
parent
4f41be67ac
commit
2ffe170407
1 changed files with 20 additions and 4 deletions
|
|
@ -231,8 +231,8 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
var token = e.Token == default ? _updateToken : e.Token;
|
||||
|
||||
// make a copy of results to avoid plugin change the result when updating view model
|
||||
var resultsCopy = e.Results.ToList();
|
||||
// make a clone to avoid possible issue that plugin will also change the list and items when updating view model
|
||||
var resultsCopy = DeepCloneResults(e.Results, token);
|
||||
|
||||
PluginManager.UpdatePluginMetadata(resultsCopy, pair.Metadata, e.Query);
|
||||
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(resultsCopy, pair.Metadata, e.Query,
|
||||
|
|
@ -414,6 +414,22 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyList<Result> DeepCloneResults(IReadOnlyList<Result> results, CancellationToken token = default)
|
||||
{
|
||||
var resultsCopy = new List<Result>();
|
||||
foreach (var result in results.ToList())
|
||||
{
|
||||
if (token.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var resultCopy = result.Clone();
|
||||
resultsCopy.Add(resultCopy);
|
||||
}
|
||||
return resultsCopy;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BasicCommands
|
||||
|
|
@ -1469,9 +1485,9 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (_topMostRecord.IsTopMost(result))
|
||||
{
|
||||
result.Score = Result.MaxScore;
|
||||
result.Score = 100000; //Result.MaxScore;
|
||||
}
|
||||
else if (result.Score != Result.MaxScore)
|
||||
else
|
||||
{
|
||||
var priorityScore = metaResults.Metadata.Priority * 150;
|
||||
result.Score += result.AddSelectedCount ?
|
||||
|
|
|
|||
Loading…
Reference in a new issue