Skip to content

Commit 5aed8ec

Browse files
committed
enhance: commit searching (#2711)
- `Ctrl+Shift+F` will toggle commit searching - Focus the input box when the commit searching panel is visible Signed-off-by: leo <longshuang@msn.cn>
1 parent d93b7b8 commit 5aed8ec

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/Views/CommitSearchView.axaml.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using Avalonia;
12
using Avalonia.Controls;
23
using Avalonia.Input;
4+
using Avalonia.Threading;
35

46
namespace SourceGit.Views
57
{
@@ -10,6 +12,14 @@ public CommitSearchView()
1012
InitializeComponent();
1113
}
1214

15+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
16+
{
17+
base.OnPropertyChanged(change);
18+
19+
if (change.Property == IsVisibleProperty && IsVisible)
20+
Dispatcher.UIThread.Post(() => TxtSearchCommitsBox.Focus(NavigationMethod.Directional), DispatcherPriority.Background);
21+
}
22+
1323
private void OnSearchBoxKeyDown(object _, KeyEventArgs e)
1424
{
1525
if (DataContext is not ViewModels.SearchCommitContext ctx)

‎src/Views/Launcher.axaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ protected override async void OnKeyDown(KeyEventArgs e)
272272
e.Handled = true;
273273
return;
274274
case Key.F when e.KeyModifiers.HasFlag(KeyModifiers.Shift):
275-
repo.Histories.IsSearchingCommits = true;
275+
repo.Histories.IsSearchingCommits = !repo.Histories.IsSearchingCommits;
276276
e.Handled = true;
277277
return;
278278
case Key.B when e.KeyModifiers.HasFlag(KeyModifiers.Shift):

0 commit comments

Comments
 (0)