diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 66291659a..c49ac5fe7 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -662,8 +662,7 @@ private void CalcRevisionFileSearchSuggestion() var suggestion = new List(); foreach (var file in _revisionFiles) { - if (file.Contains(_revisionFileSearchFilter, StringComparison.OrdinalIgnoreCase) && - file.Length != _revisionFileSearchFilter.Length) + if (file.Contains(_revisionFileSearchFilter, StringComparison.OrdinalIgnoreCase)) suggestion.Add(file); if (suggestion.Count >= 100) diff --git a/src/Views/RevisionFileTreeView.axaml b/src/Views/RevisionFileTreeView.axaml index 025ba4d79..4d4c9d034 100644 --- a/src/Views/RevisionFileTreeView.axaml +++ b/src/Views/RevisionFileTreeView.axaml @@ -8,7 +8,8 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.RevisionFileTreeView" x:Name="ThisControl"> - (); @@ -324,7 +323,27 @@ public async Task SetSearchResultAsync(string file) MakeRows(rows, _searchResult, 0); } - Rows.AddRange(rows); + _disableSelectionChangingEvent = true; + try + { + Rows.Clear(); + Rows.AddRange(rows); + } + finally + { + _disableSelectionChangingEvent = false; + } + + if (!string.IsNullOrEmpty(file)) + { + var target = rows.Find(x => !x.IsFolder); + if (target != null) + { + RowsList.SelectedItem = target; + RowsList.ScrollIntoView(target); + } + } + GC.Collect(); } diff --git a/src/Views/RevisionFiles.axaml b/src/Views/RevisionFiles.axaml index 9ff113c57..80ce1f980 100644 --- a/src/Views/RevisionFiles.axaml +++ b/src/Views/RevisionFiles.axaml @@ -63,6 +63,7 @@ ItemsSource="{Binding RevisionFileSearchSuggestion}" MaxHeight="400" Focusable="True" + SelectionChanged="OnSearchSuggestionSelectionChanged" KeyDown="OnSearchSuggestionBoxKeyDown">