diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index a9f62516..47ca8e10 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -369,6 +369,18 @@ namespace SourceGit.ViewModels return menu; } + public void NotifyAutoSelectedCommitChanged() + { + if (DetailContext is CommitDetail detail) + { + _repo.HandleSelectedCommitChanged(detail.Commit); + } + else + { + _repo.HandleSelectedCommitChanged(null); + } + } + private void FillCurrentBranchMenu(ContextMenu menu, Models.Branch current) { var submenu = new MenuItem(); diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index bff80053..89807206 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -221,6 +221,12 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _hasUnsolvedConflicts, value); } + public Models.Commit SearchResultSelectedCommit + { + get => _searchResultSelectedCommit; + set => SetProperty(ref _searchResultSelectedCommit, value); + } + public void Open() { _watcher = new Models.Watcher(this); @@ -1348,6 +1354,14 @@ namespace SourceGit.ViewModels return menu; } + public void HandleSelectedCommitChanged(Models.Commit commit) + { + if (SearchedCommits.Count > 0) + { + SearchResultSelectedCommit = commit; + } + } + private string _fullpath = string.Empty; private string _gitDir = string.Empty; private Models.GitFlow _gitflow = new Models.GitFlow(); @@ -1377,5 +1391,6 @@ namespace SourceGit.ViewModels private InProgressContext _inProgressContext = null; private bool _hasUnsolvedConflicts = false; + private Models.Commit _searchResultSelectedCommit = null; } } diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 13f05aff..cbed193b 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -291,6 +291,7 @@ namespace SourceGit.Views if (DataContext is ViewModels.Histories histories) { histories.Select(commitDataGrid.SelectedItems); + histories.NotifyAutoSelectedCommitChanged(); } e.Handled = true; } diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 1423807d..c854faa2 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -403,6 +403,7 @@