Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible result update issue for plugins with IResultUpdate interface #3115

Merged
merged 4 commits into from
Dec 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,26 +1447,35 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
}
#endif

foreach (var metaResults in resultsForUpdates)
try
{
foreach (var result in metaResults.Results)
foreach (var metaResults in resultsForUpdates)
{
if (_topMostRecord.IsTopMost(result))
{
result.Score = int.MaxValue;
}
else
foreach (var result in metaResults.Results)
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
if (_topMostRecord.IsTopMost(result))
{
result.Score = int.MaxValue;
}
else
{
var priorityScore = metaResults.Metadata.Priority * 150;
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
}
}
}
}

// it should be the same for all results
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;
// it should be the same for all results
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;

Results.AddResults(resultsForUpdates, token, reSelect);
Results.AddResults(resultsForUpdates, token, reSelect);
}
catch (InvalidOperationException e)
{
// Plugin with IResultUpdate interface can somtimes throw this exception
// Collection was modified; enumeration operation may not execute
Log.Exception($"{nameof(MainViewModel)}.{nameof(UpdateResultView)}|UpdateResultView failed", e);
}
Jack251970 marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
Loading