diff --git a/ILSpy/Search/SearchPane.cs b/ILSpy/Search/SearchPane.cs index 204457c08..54fc2cad9 100644 --- a/ILSpy/Search/SearchPane.cs +++ b/ILSpy/Search/SearchPane.cs @@ -49,6 +49,7 @@ namespace ICSharpCode.ILSpy const int MAX_REFRESH_TIME_MS = 10; // More means quicker forward of data, less means better responsibility RunningSearch currentSearch; bool runSearchOnNextShow; + IComparer resultsComparer; public static readonly DependencyProperty ResultsProperty = DependencyProperty.Register("Results", typeof(ObservableCollection), typeof(SearchPane), @@ -211,7 +212,7 @@ namespace ICSharpCode.ILSpy int resultsAdded = 0; while (Results.Count < MAX_RESULTS && timer.ElapsedMilliseconds < MAX_REFRESH_TIME_MS && currentSearch.resultQueue.TryTake(out var result)) { - InsertResult(Results, result); + Results.InsertSorted(result, resultsComparer); ++resultsAdded; } @@ -230,6 +231,9 @@ namespace ICSharpCode.ILSpy currentSearch = null; } + resultsComparer = DisplaySettingsPanel.CurrentDisplaySettings.SortResults ? + SearchResult.ComparerByFitness : + SearchResult.ComparerByName; Results.Clear(); RunningSearch startedSearch = null; @@ -252,15 +256,6 @@ namespace ICSharpCode.ILSpy } } - void InsertResult(IList results, SearchResult result) - { - var comparer = DisplaySettingsPanel.CurrentDisplaySettings.SortResults ? - SearchResult.ComparerByFitness : - SearchResult.ComparerByName; - - results.InsertSorted(result, comparer); - } - void JumpToSelectedItem() { if (listBox.SelectedItem is SearchResult result)