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 @@ -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<SearchResult> resultsComparer;
public static readonly DependencyProperty ResultsProperty =
DependencyProperty.Register("Results", typeof(ObservableCollection<SearchResult>), typeof(SearchPane),
@ -211,7 +212,7 @@ namespace ICSharpCode.ILSpy @@ -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 @@ -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 @@ -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()
{
if (listBox.SelectedItem is SearchResult result)

Loading…
Cancel
Save