feature: enhance commit search

* Supports search commits by author/committer email
* Auto focus when search panel is visible
This commit is contained in:
leo 2024-03-07 16:18:51 +08:00
parent f65dc36e62
commit d0e80be79f
3 changed files with 12 additions and 2 deletions

View file

@ -292,7 +292,9 @@ namespace SourceGit.ViewModels {
|| c.Subject.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|| c.Message.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|| c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)) {
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|| c.Committer.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)) {
visible.Add(c);
}
}

View file

@ -346,10 +346,11 @@
</Grid>
<!-- Left Search Mode -->
<Grid Grid.Column="0" RowDefinitions="32,*" IsVisible="{Binding IsSearching}">
<Grid Grid.Column="0" RowDefinitions="32,*" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
<!-- Search -->
<Grid Grid.Row="0" Margin="4,2">
<TextBox Grid.Column="1"
x:Name="txtSearchCommitsBox"
Padding="22,0"
FontSize="12"
Height="24"

View file

@ -88,6 +88,13 @@ namespace SourceGit.Views {
}
}
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) {
var grid = sender as Grid;
if (e.Property == IsVisibleProperty && grid.IsVisible) {
txtSearchCommitsBox.Focus();
}
}
private void OnSearchKeyDown(object sender, KeyEventArgs e) {
if (e.Key == Key.Enter) {
if (DataContext is ViewModels.Repository repo) {