Skip to content

Commit d8c07a5

Browse files
committed
Fix result update issue during modified collection enumeration
1 parent c474b30 commit d8c07a5

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading;
@@ -1440,26 +1440,33 @@ public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
14401440
}
14411441
#endif
14421442

1443-
foreach (var metaResults in resultsForUpdates)
1443+
try
14441444
{
1445-
foreach (var result in metaResults.Results)
1445+
foreach (var metaResults in resultsForUpdates)
14461446
{
1447-
if (_topMostRecord.IsTopMost(result))
1448-
{
1449-
result.Score = int.MaxValue;
1450-
}
1451-
else
1447+
foreach (var result in metaResults.Results)
14521448
{
1453-
var priorityScore = metaResults.Metadata.Priority * 150;
1454-
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
1449+
if (_topMostRecord.IsTopMost(result))
1450+
{
1451+
result.Score = int.MaxValue;
1452+
}
1453+
else
1454+
{
1455+
var priorityScore = metaResults.Metadata.Priority * 150;
1456+
result.Score += _userSelectedRecord.GetSelectedCount(result) + priorityScore;
1457+
}
14551458
}
14561459
}
1457-
}
14581460

1459-
// it should be the same for all results
1460-
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;
1461+
// it should be the same for all results
1462+
bool reSelect = resultsForUpdates.First().ReSelectFirstResult;
14611463

1462-
Results.AddResults(resultsForUpdates, token, reSelect);
1464+
Results.AddResults(resultsForUpdates, token, reSelect);
1465+
}
1466+
catch (Exception ex)
1467+
{
1468+
Log.Debug("MainViewModel", $"Error in UpdateResultView: {ex.Message}");
1469+
}
14631470
}
14641471

14651472
#endregion

0 commit comments

Comments
 (0)