Browse Source

Move comparer selection to start of search

pull/2335/head
MikeFH 4 years ago
parent
commit
590ebee47e
  1. 15
      ILSpy/Search/SearchPane.cs

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

Loading…
Cancel
Save