mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
feature: add auto complete box for searching commits by file path
This commit is contained in:
parent
addfb449cc
commit
7f8b8a19a0
4 changed files with 235 additions and 35 deletions
|
@ -29,11 +29,33 @@ namespace SourceGit.Views
|
|||
|
||||
private void OnSearchKeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo && !string.IsNullOrWhiteSpace(repo.SearchCommitFilter))
|
||||
if (!string.IsNullOrWhiteSpace(repo.SearchCommitFilter))
|
||||
repo.StartSearchCommits();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Down)
|
||||
{
|
||||
if (repo.IsSearchCommitSuggestionOpen)
|
||||
{
|
||||
SearchSuggestionBox.Focus(NavigationMethod.Tab);
|
||||
SearchSuggestionBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
if (repo.IsSearchCommitSuggestionOpen)
|
||||
{
|
||||
repo.SearchCommitFilterSuggestion.Clear();
|
||||
repo.IsSearchCommitSuggestionOpen = false;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
@ -272,5 +294,37 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchSuggestionBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
repo.IsSearchCommitSuggestionOpen = false;
|
||||
repo.SearchCommitFilterSuggestion.Clear();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Enter && SearchSuggestionBox.SelectedItem is string content)
|
||||
{
|
||||
repo.SearchCommitFilter = content;
|
||||
TxtSearchCommitsBox.CaretIndex = content.Length;
|
||||
repo.StartSearchCommits();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchSuggestionDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
var repo = DataContext as ViewModels.Repository;
|
||||
var content = (sender as StackPanel)?.DataContext as string;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
repo.SearchCommitFilter = content;
|
||||
TxtSearchCommitsBox.CaretIndex = content.Length;
|
||||
repo.StartSearchCommits();
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue